Reputation: 117
I am living in Quebec, which is in EST time zone.
When I use
date_default_timezone_set('EST');
echo date("m/d/Y h:i:s");
I will get the time that's one hour different than my current time.
Now I can only manually correct the time using
$time = strtotime('+1 hour');
echo date("m/d/Y h:i:s",$time);
I don't know how to make the program to change the time to summer time automatically.
I heard that date("I")
would return true if it is in the summer time?
I am not sure about that.
Upvotes: 2
Views: 678
Reputation: 40881
EST
would be Eastern Standard Time. You're looking for Eastern Daylight Savings Time. Best to choose your locale from the supported locations so that you don't have to manually keep track of this.
For example, here's New York which is DST right now (2017-08-11):
<?php
echo date_default_timezone_get() . ' : ' . date("m/d/Y h:i:s") . PHP_EOL;
date_default_timezone_set('EST');
echo date_default_timezone_get() . ' : ' . date("m/d/Y h:i:s") . PHP_EOL;
date_default_timezone_set('America/New_York');
echo date_default_timezone_get() . ' : ' . date("m/d/Y h:i:s") . PHP_EOL;
UTC : 08/11/2017 03:54:07 EST : 08/10/2017 10:54:07 America/New_York : 08/10/2017 11:54:07
Upvotes: 2