Jump to content

How can I add 5 minutes to a visitors local time?


Webwonder

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.