How do I add 24 hours to a unix timestamp in php?


I would like to add 24 hours to the timestamp for now. How do I find the unix timestamp number for 24 hours so I can add it to the timestamp for right now?

I also would like to know how to add 48 hours or multiple days to the current timestamp.

How can I go best about doing this?

3/25/2010 11:37:16 AM

Accepted Answer

You probably want to add one day rather than 24 hours. Not all days have 24 hours due to (among other circumstances) daylight saving time:

strtotime('+1 day', $timestamp);
1/25/2018 10:46:31 AM

A Unix timestamp is simply the number of seconds since January the first 1970, so to add 24 hours to a Unix timestamp we just add the number of seconds in 24 hours. (24 * 60 *60)

time() + 24*60*60;

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow