Not displaying right timezone for Australia

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Stella1229
Forum Newbie
Posts: 10
Joined: Thu Nov 14, 2013 1:24 pm

Not displaying right timezone for Australia

Post 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 :(
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Not displaying right timezone for Australia

Post 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).
Stella1229
Forum Newbie
Posts: 10
Joined: Thu Nov 14, 2013 1:24 pm

Re: Not displaying right timezone for Australia

Post 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?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Not displaying right timezone for Australia

Post by Weirdan »

Updated the post, see PS: above.
Stella1229
Forum Newbie
Posts: 10
Joined: Thu Nov 14, 2013 1:24 pm

Re: Not displaying right timezone for Australia

Post 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
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Not displaying right timezone for Australia

Post by Weirdan »

// 1 <-- mmmm.. this is not
Works fine for me (prints '1' followed by '0'). What's your php version and distro?
Stella1229
Forum Newbie
Posts: 10
Joined: Thu Nov 14, 2013 1:24 pm

Re: Not displaying right timezone for Australia

Post by Stella1229 »

PHP Version 5.4.19?
Stella1229
Forum Newbie
Posts: 10
Joined: Thu Nov 14, 2013 1:24 pm

Re: Not displaying right timezone for Australia

Post by Stella1229 »

and xampp
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Not displaying right timezone for Australia

Post by Weirdan »

Stella1229 wrote:and xampp
For Linux, Windows or Mac?
Stella1229
Forum Newbie
Posts: 10
Joined: Thu Nov 14, 2013 1:24 pm

Re: Not displaying right timezone for Australia

Post by Stella1229 »

windows

(have I thanked you yet for all your help so far?)
Stella1229
Forum Newbie
Posts: 10
Joined: Thu Nov 14, 2013 1:24 pm

Re: Not displaying right timezone for Australia

Post by Stella1229 »

wow.. it's working now for some reason.. that's super weird!

Thank you, Mr Moderator, for all your help :)
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Not displaying right timezone for Australia

Post 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.
Post Reply