HardCoreMore Posted April 10, 2008 Share Posted April 10, 2008 Hi i am havin a problem. I can print current date to browser with this script without problem : $date = getdate ( time()); $currentDate = $date ['year']."-".$date['mon']."-". $date['mday']." ". $date ['hours'] .":".$date['minutes'].":". $date['seconds']; print $currentDate; But how can i add just 24 hours to the $currentDate or subtract 24 hours; Any idea? Link to comment https://forums.phpfreaks.com/topic/100544-add-24-hours-to-current-date/ Share on other sites More sharing options...
Zhadus Posted April 10, 2008 Share Posted April 10, 2008 Add (24*60*60) to your time(). That should do the trick for you. Link to comment https://forums.phpfreaks.com/topic/100544-add-24-hours-to-current-date/#findComment-514249 Share on other sites More sharing options...
AndyB Posted April 10, 2008 Share Posted April 10, 2008 I use this: <?php list($y,$m,$d,$h,$i) = explode("-", date("Y-m-d-H-i")); echo date("Y-m-d H:i"), mktime($h+24,$i,0,$m,$d,$y)); // +24 is the adder you want. Your choice of format ?> Link to comment https://forums.phpfreaks.com/topic/100544-add-24-hours-to-current-date/#findComment-514251 Share on other sites More sharing options...
HardCoreMore Posted April 10, 2008 Author Share Posted April 10, 2008 Thanks people really appriciated. I change my code from this getdate ( time()); to this getdate ( time()+(5*60*60)); and now i have adition or subtraction of how many hours i want. Great, thanks alot! Link to comment https://forums.phpfreaks.com/topic/100544-add-24-hours-to-current-date/#findComment-514256 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.