2
Contributors
4
Replies
11
Views
4 Years
Discussion Span
Last Post by LastMitch
0

@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/

Edited by LastMitch: grammer

0

@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

1

@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

Edited by vaultdweller123

1

@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.

Edited by LastMitch: grammer

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.