By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,982 Members | 1,919 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,982 IT Pros & Developers. It's quick & easy.

How to identify Daylight saving Time

100+
P: 119
Hi All,

I am trying for something in Daylight saving time. I have a eastern time stamp and the timezone (possible timezones CST,EST,PST,MST,HST). Basically these are two input which is required for my daylight saving time calculation.

If the time zone is CST i have to convert the given eastern timestamp to central timestamp.
like

Expand|Select|Wrap|Line Numbers
  1. if ($timezone == "CST")
  2. $central = $eastern - 3600; 
  3.  
Now i have to find whether the given central timestamp ($central) is coming under the Daylight saving time or not. Can some one help me how to find daylight saving is true or false.?

Thanks in advance,

Thanks,
Magesh
Dec 7 '11 #1

✓ answered by dlite922

See date() manual.

What you're looking for is the Capital "I" which return 1 if daylight saving (summer march-november) and 0 if not (winter november-march).

So what you could do is some kind of calculation on your timezone, such as:

Expand|Select|Wrap|Line Numbers
  1.  
  2. $cental = $eastern - 3600 + (date('I') * 3600);
  3.  
  4.  
if date('I') returns zero, then 0*3600=0 basically adding nothing. If it is daylight savings time, then you add one more hour. IF $eastern is not already in daylight savings time.

Eastern standard time (EST) always equals central daylight time (CDT), in the math above:

$CDT = $EST - 3600 + 3600;
$CDT = $EST + 0;

Hope that helped,


Dan

Share this Question
Share on Google+
1 Reply


dlite922
Expert 100+
P: 1,584
See date() manual.

What you're looking for is the Capital "I" which return 1 if daylight saving (summer march-november) and 0 if not (winter november-march).

So what you could do is some kind of calculation on your timezone, such as:

Expand|Select|Wrap|Line Numbers
  1.  
  2. $cental = $eastern - 3600 + (date('I') * 3600);
  3.  
  4.  
if date('I') returns zero, then 0*3600=0 basically adding nothing. If it is daylight savings time, then you add one more hour. IF $eastern is not already in daylight savings time.

Eastern standard time (EST) always equals central daylight time (CDT), in the math above:

$CDT = $EST - 3600 + 3600;
$CDT = $EST + 0;

Hope that helped,


Dan
Dec 12 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.