Jump to content

date("G", $offset) Hates me.


eugeniu

Recommended Posts

I'm writing a script that determines the time for a specified timezone. Here's the code for generating the time:

 

<?php

$offset = $hoursGMT + $timezone;
if ($dst == "off") $offset++;

$hoursoff = $offset;
$offset = $offset * 60 * 60;
if ($format == 24) {
$hour = date("G", $offset);
} elseif ($format == 12) {
$hour = date("g", $offset);
}

$time = $hour . ":" . date(i) . ":" . date(s);		

$meridiem = date("A", $offset);

?>

 

$hoursGMT is -8, the number of hours away from GMT (+00:00) time. $timezone is the pre-specified timezone, from -11 to 12. From those two variables, I can determine $offset, the seconds in the future or in the past that

 

Yesterday, this code worked in what I'm pretty sure is the same code I have now, but it's been acting very messed up since this morning, displaying inaccurate hours. Which leads me to believe that something must've changed since yesterday, but I can't figure out what it is.

 

Edit: It appears that now, in the afternoon, it's working normally again. Apparently there's only a problem when the server is in AM time.

Link to comment
https://forums.phpfreaks.com/topic/164451-dateg-offset-hates-me/
Share on other sites

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.