Question regarding timestamps.
#1

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.
Reply
#2

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)
Reply
#3

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)