-1

What I'm trying to do is get the correct time of the user browsing my website and add 10 minutes to the current time. Here is hte code I have:

<?php
$now = time();
$closetime = $now+600;
echo strftime("%A %b %e %I:%M%p %Z",$closetime) . "\n";
?>

Everything works as I intended, the only issue that the timezone is off. I'm currently on the eastcoast so its 12:55 here, but the above code would output: Monday Oct 7 12:05PM CDT which is 1 hour behind what I want.

How do I make this appear correctly for the user so no matter what country or timezone it will always display 10 minutes from the current time?

Joe Bobby
  • 2,803
  • 10
  • 40
  • 59

1 Answers1

1

Check the timezone you are using with ini_get('date.timezone'). If isn't the right timezone search for date.timezone in your php.ini file and edit the value for one of the supported timezones values that PHP have.

date.timezone = "America/Los_Angeles"

If you don't have access to the php.ini file you can overwrite that value with date_default_timezone_set function at the begining of your app evertytime it is executed.

Andrés Torres
  • 747
  • 5
  • 16