SA-MP Forums Archive
Question regarding timestamps. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question regarding timestamps. (/showthread.php?tid=509112)



Question regarding timestamps. - Dokins - 25.04.2014

I'm looking to do something like this:

I /setdate - This adds 2 weeks to the current time.
(I know how to do this).

But what I want to do, is check if it's that DAY not the exact time, so basically.


How do set the timestamp to be set at midnight (when the new day starts) of that day 2 weeks later, instead of the time it currently is + 2 weeks?

Thanks in advance.


Re: Question regarding timestamps. - Vince - 25.04.2014

Since each day consists of 86400 seconds, we can use that as an operator to the modulus to find out how many second we need to subtract from the timestamp.
Код:
Current timestamp: 1398444232 
1398444232 % 86400 = 60232
1398444232 - 60232 = 1398384000
Converted to human readable: 04 / 25 / 14 @ 12:00:00am UTC
Then just add 14 days. (14 * 24 * 60 * 60)


Re: Question regarding timestamps. - Dokins - 25.04.2014

I'm not exactly sure how that works, I mean. 86400 is a day, right but I'm not sure how you get midnight if you take away? surely that = 24 hours?