gple Posted October 24, 2007 Share Posted October 24, 2007 if i have a variable 'time', and I want to create a new variable which is an hour and fifteen minutes after the 'time' variable. how do i write that? Quote Link to comment https://forums.phpfreaks.com/topic/74634-adding-time/ Share on other sites More sharing options...
only one Posted October 24, 2007 Share Posted October 24, 2007 $time = time() + 4500; //time + 75 minutes in seconds. Quote Link to comment https://forums.phpfreaks.com/topic/74634-adding-time/#findComment-377243 Share on other sites More sharing options...
kenrbnsn Posted October 24, 2007 Share Posted October 24, 2007 What is the format of your variable? If it is "hh:mm:ss", use the strtotime() function in combination with the date() function: <?php $time = '9:00'; $new_time = date('H:i',strtotime($time . '+ 1 hour + 15 minutes')); echo $time . ' ... ' . $new_time . "<br>"; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/74634-adding-time/#findComment-377253 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.