hey guys... just wanna ask, is setting timezone on php automatically computes for daylight saving times? i mean does it autmatically detect DST and automaticaly add +1 hour on specific month? thanks in advance

Recommended Answers

All 4 Replies

Member Avatar for LastMitch

@vaultdweller123

hey guys... just wanna ask, is setting timezone on php automatically computes for daylight saving times? i mean does it autmatically detect DST and automaticaly add +1 hour on specific month? thanks in advance

I think you might read this before:

http://php.net/manual/en/function.date.php

it has list of letters that represent a format.

But to answer your question, yes if you used strtotime() function plus you also need to used this

http://www.php.net/manual/en/timezones.php

Here is an link of how this work altogether:

http://phpmaster.com/working-with-dates-and-times/

@lastmitch thank you for the reply, and yes im using php's list of supported timezone, by using PHP's date_default_timezone_set, my only concern is the DST. example

date_default_timezone_set('America/Los_Angeles');

so it automaticaly computes for DST? i don't have to manually trap it? to add 1 hour on DST enabled month? and btw thanks for the link, ill read your 3rd link :D

@lastmitch thanks for the link, i think you are right, based on the article

php > $tz = new DateTimeZone("America/New_York");
php > $dt->setTimezone($tz);
php > print $dt->gt;format("r");
Tue, 20 Dec 2011 15:57:45 -0500

Notice the -0500 offset for the month of December. If you change the the time value to a summer date, such as July 1, you’ll see it is aware of Daylight Savings Time (EDT)

php > $tz = new DateTimeZone("America/New_York");
php > $july = new DateTime("7/1/2011");
php > $july->setTimezone($tz);
php > print $july->>format("r");
Thu, 30 Jun 2011 20:00:00 -0400

it is aware of the DST :D

Member Avatar for LastMitch

@vaultdweller123

php > $tz = new DateTimeZone("America/New_York");
php > $dt->setTimezone($tz);
php > print $dt->gt;format("r");
Tue, 20 Dec 2011 15:57:45 -0500

Notice the -0500 offset for the month of December. If you change the the time value to a summer date, such as July 1, you’ll see it is aware of Daylight Savings Time (EDT)

php > $tz = new DateTimeZone("America/New_York");
php > $july = new DateTime("7/1/2011");
php > $july->setTimezone($tz);
php > print $july->>format("r");
Thu, 30 Jun 2011 20:00:00 -0400

I'm still new to this! Wow you did this very quickly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.