Page 1 of 1

Not displaying right timezone for Australia

Posted: Mon Nov 25, 2013 7:05 pm
by Stella1229
I cannot get my program to spit out a time in AEDT or AEST.

For example:
Current time in Sydney
Tuesday, November 26, 2013 at 11:59:09 AM AEDT

but when i do the following in PHP, I get back EST

Code: Select all

date_default_timezone_set("Australia/Sydney");
echo date("F j Y g:i a T\n");
I get November 26 2013 11:59 am EST

why am I not getting AEDT, but getting EST instead? I tried using Australia/Sydney, Australia/NSW, Australia/Victoria.. all the same result :(

Re: Not displaying right timezone for Australia

Posted: Mon Nov 25, 2013 7:24 pm
by Weirdan
This is AEST, just abbreviated to EST:

Code: Select all

date_default_timezone_set("Australia/Sydney");
echo date("F j Y g:i a T P e\n");
// November 26 2013 12:19 pm EST +11:00 Australia/Sydney
Google also reports the timezone as EST: https://www.google.com/search?q=time+in+sydney
12:21 PM
Tuesday, November 26, 2013 (EST)
Time in Sydney NSW, Australia
(as of time of writing)

PS: to clarify, http://www.iana.org/time-zones (the source for timezone abbreviations in PHP) uses EST to mean both "Australian Eastern Standard Time" and "Australian Eastern Summer Time" (see discussion in http://www.iana.org/time-zones/reposito ... 13h.tar.gz (australasia) file).

Re: Not displaying right timezone for Australia

Posted: Mon Nov 25, 2013 7:45 pm
by Stella1229
but shouldn't it be EDT (if it's just a matter of abbreviation)? Since Australia is currently at their daylight savings time?

Re: Not displaying right timezone for Australia

Posted: Mon Nov 25, 2013 7:53 pm
by Weirdan
Updated the post, see PS: above.

Re: Not displaying right timezone for Australia

Posted: Tue Nov 26, 2013 2:40 pm
by Stella1229
OK don't hate me.. but it's still not right..

According to Australia.gov.au (http://australia.gov.au/about-australia ... untry/time),
"Daylight Saving Time begins at 2am on the first Sunday in October, when clocks are put forward one hour. It ends at 2am (which is 3am Daylight Saving Time) on the first Sunday in April, when clocks are put back one hour."

This means
April 20, 2013 --> Standard Time
And
Oct 13, 2013 -> Daylight Savings Time


According to http://php.net/manual/en/function.date.php, I can use I (capital i) to see if the two dates above are within daylight savings or standard time (1 == daylight savings time, 0 == standard time)

Code: Select all

date_default_timezone_set("Australia/Sydney");
$strInputDateTime = strtotime("2013-10-13 00:00");
echo date("I", $strInputDateTime);
// 1 <-- this is right

date_default_timezone_set("Australia/Sydney");
$strInputDateTime = strtotime("2013-04-20 00:00");
echo date("I", $strInputDateTime);
// 1 <-- mmmm.. this is not 
am I completely losing my mind?

Self-proclaimed Poor Noob

Re: Not displaying right timezone for Australia

Posted: Tue Nov 26, 2013 3:08 pm
by Weirdan
// 1 <-- mmmm.. this is not
Works fine for me (prints '1' followed by '0'). What's your php version and distro?

Re: Not displaying right timezone for Australia

Posted: Tue Nov 26, 2013 4:15 pm
by Stella1229
PHP Version 5.4.19?

Re: Not displaying right timezone for Australia

Posted: Tue Nov 26, 2013 4:36 pm
by Stella1229
and xampp

Re: Not displaying right timezone for Australia

Posted: Tue Nov 26, 2013 4:49 pm
by Weirdan
Stella1229 wrote:and xampp
For Linux, Windows or Mac?

Re: Not displaying right timezone for Australia

Posted: Tue Nov 26, 2013 5:17 pm
by Stella1229
windows

(have I thanked you yet for all your help so far?)

Re: Not displaying right timezone for Australia

Posted: Tue Nov 26, 2013 8:44 pm
by Stella1229
wow.. it's working now for some reason.. that's super weird!

Thank you, Mr Moderator, for all your help :)

Re: Not displaying right timezone for Australia

Posted: Tue Nov 26, 2013 8:49 pm
by Weirdan
wow.. it's working now for some reason.. that's super weird!
Then either you did something wrong previously, doing something wrong now or something happened (like process/server restart). Glad it's working for you though :D.