Webwonder Posted July 3, 2008 Share Posted July 3, 2008 I need to be able to add 5 minutes to my visitors local time and show it on their page. I want to make sure that the time it shows is their geographical local time + 5 minutes. How can this be done? Link to comment https://forums.phpfreaks.com/topic/113022-how-can-i-add-5-minutes-to-a-visitors-local-time/ Share on other sites More sharing options...
ag3nt42 Posted July 3, 2008 Share Posted July 3, 2008 echo(gmstrftime(%H).":"); echo(gmstrftime(%M)+5.":"); echo(gmstrftime(%S).":"); that should work.. not tested Link to comment https://forums.phpfreaks.com/topic/113022-how-can-i-add-5-minutes-to-a-visitors-local-time/#findComment-580570 Share on other sites More sharing options...
ofs Posted July 3, 2008 Share Posted July 3, 2008 I had never heard of the strftime() function, maybe it's a better solution if that code works. Here was my solution: <?php $local = localtime($time, true); echo "Now: ".$local['tm_hour']." : ".$local['tm_min']."<br />"; $latermin = $localplus['tm_min'] + 5; if($latermin >= 60) { $laterhr++; if($laterhr == 24) { $laterhr = "00"; } $latermin = $latermin - 60; if(strlen($latermin) == 1) { $latermin = "0"+$latermin; } } echo "Later: ".$laterhr." : ".$latermin; ?> Seems a little inefficient... But it works. Also, this is for 24-hour time... 12-hour time would be just another few lines of very inefficient code. Link to comment https://forums.phpfreaks.com/topic/113022-how-can-i-add-5-minutes-to-a-visitors-local-time/#findComment-580578 Share on other sites More sharing options...
ag3nt42 Posted July 3, 2008 Share Posted July 3, 2008 i thought about doing that very same thing but I figured it was way to time consuming so i searched the php date functions for a time function and found those http://w3schools.com/php/func_date_gmstrftime.asp Link to comment https://forums.phpfreaks.com/topic/113022-how-can-i-add-5-minutes-to-a-visitors-local-time/#findComment-580579 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.