I'm sorry if I'm asking something that someone has already answered but I've searched the forums. If I understand correctly, X10 servers are located on the East coast of the USA. I am also located in this region.
When inputting data into mySQL and using a field with CURRENT_TIMESTAMP default value, mySQL will produce a time stamp that is 1 hour behind my current time. I'm assuming this is because of daylight savings.
When inputting this code in php I also have a time that is 1 hour behind.
The output is:
Questions:
1. Are mySQL and php outputs always going to read the EST time without regard of daylight savings, always UTC - 5 hours?
2. When the php output reads CDT (which is equal to EST) is that just irrelevant? Why does it show Chicago if X10 servers are in NY?
3. Most importantly, will anything change when daylight savings is off and the East coast goes back to EST? I'm fine with php output reading CDT as long as the time is really EST. In other words, when the East coast goes back to EST (daylight savings off) will my PC time = mySQL = php output?
4. Finally, any ideas as to why this code does not properly convert the EST time to UTC? Note: Record 10 was added at 12:45AM EST / 4:45AM UTC
It shows the UTC time one hour behind. Why is DateTimeZone('EST') seeming to take daylight savings into consideration? Output below:
Thanks for your help.
When inputting data into mySQL and using a field with CURRENT_TIMESTAMP default value, mySQL will produce a time stamp that is 1 hour behind my current time. I'm assuming this is because of daylight savings.
When inputting this code in php I also have a time that is 1 hour behind.
PHP:
echo date("HiTe");
2330CDTAmerica/Chicago
Questions:
1. Are mySQL and php outputs always going to read the EST time without regard of daylight savings, always UTC - 5 hours?
2. When the php output reads CDT (which is equal to EST) is that just irrelevant? Why does it show Chicago if X10 servers are in NY?
3. Most importantly, will anything change when daylight savings is off and the East coast goes back to EST? I'm fine with php output reading CDT as long as the time is really EST. In other words, when the East coast goes back to EST (daylight savings off) will my PC time = mySQL = php output?
4. Finally, any ideas as to why this code does not properly convert the EST time to UTC? Note: Record 10 was added at 12:45AM EST / 4:45AM UTC
PHP:
$now = mysql_result(mysql_query("SELECT created FROM listings WHERE id = 10"), 0);
echo $now . '<br>';
$date = new DateTime($now, new DateTimeZone('EST'));
echo $date->format('Y-m-d H:i:s') . '<br>';
$date->setTimezone(new DateTimeZone('UTC'));
echo $date->format('Y-m-d H:i:s');
2013-09-19 23:45:34
2013-09-19 23:45:34
2013-09-20 03:45:34
Thanks for your help.