Jump to content

how to get correct gmdate()


jasonc

Recommended Posts

I have using gmdate() to get the GMT time but as it does not take in to account daylight saving the time is one hour behind.

 

Does anyone have a fix that can work out the correct time what ever time of year it is?

 

As I am currently having to change the code each time the time changes.

Link to comment
https://forums.phpfreaks.com/topic/214264-how-to-get-correct-gmdate/
Share on other sites

gmdate will get the correct time in GMT... however that is not what you want (obviously).  There are a couple of ways, here's two.

 

// I'm assuming this is the timezone you really  want
// It could also (instead) be set in a .htaccess or php.ini file
date_default_timezone_set('Europe/London');
$now = date($format);

 

$now = date_create('now', new DateTimeZone('Europe/London'))->format($format);

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.