For posterity's sake, here is an algorithm I created to take a GMT
time and convert it to U.S. central time, accounting for daylight
saving time. Note: this algorithm can be modified to work for any
other U.S. timezone by changing the number of second subtracted at the
end.
<?
$in_dst="false" ;
if( (date(m)>=4) && (date(m)<=10) ) // IS CURRENT DATE INSIDE OF
APRIL->OCT WINDOW?
{
if( (date(m)>4) && (date(m)<10) ) //IS CURRENT DATE INSIDE
MAY->SEPT WINDOW?
{
$in_dst="true";
}
elseif($date(m) =="4") //IS IT APRIL?
{
if( (date(j)<=7) && (date(D)=="Sun" ) ) //IS IT THE FIRST SUN OF
THE MONTH?
{
if(date(H)>"1") //IS IT PAST 2:00AM?
{
$in_dst="true";
}
}
}
elseif($date(m) =="10") //IS IT OCT?
{
if( (date(j)<=25) && (date(D)=="Sun" ) ) //IS IT THE LAST SUN OF
THE MONTH?
{
if(date(H)>"1") //IS IT PAST 2:00AM?
{
$in_dst="false" ;
}
}
}
}
if($in_dst=="tr ue") //INSIDE OF DST
{
$date=date("Y:m :dH:i:s",time()-18000); //CHANGE NUMBER OF SECONDS
HERE TO MODIFY
}
else //OUT OF DST
{
$date=date("Y:m :dH:i:s",time()-21600); //CHANGE NUMBER OF SECONDS
HERE TO MODIFY
}
?>
Please post any possible bugs you guys find.
time and convert it to U.S. central time, accounting for daylight
saving time. Note: this algorithm can be modified to work for any
other U.S. timezone by changing the number of second subtracted at the
end.
<?
$in_dst="false" ;
if( (date(m)>=4) && (date(m)<=10) ) // IS CURRENT DATE INSIDE OF
APRIL->OCT WINDOW?
{
if( (date(m)>4) && (date(m)<10) ) //IS CURRENT DATE INSIDE
MAY->SEPT WINDOW?
{
$in_dst="true";
}
elseif($date(m) =="4") //IS IT APRIL?
{
if( (date(j)<=7) && (date(D)=="Sun" ) ) //IS IT THE FIRST SUN OF
THE MONTH?
{
if(date(H)>"1") //IS IT PAST 2:00AM?
{
$in_dst="true";
}
}
}
elseif($date(m) =="10") //IS IT OCT?
{
if( (date(j)<=25) && (date(D)=="Sun" ) ) //IS IT THE LAST SUN OF
THE MONTH?
{
if(date(H)>"1") //IS IT PAST 2:00AM?
{
$in_dst="false" ;
}
}
}
}
if($in_dst=="tr ue") //INSIDE OF DST
{
$date=date("Y:m :dH:i:s",time()-18000); //CHANGE NUMBER OF SECONDS
HERE TO MODIFY
}
else //OUT OF DST
{
$date=date("Y:m :dH:i:s",time()-21600); //CHANGE NUMBER OF SECONDS
HERE TO MODIFY
}
?>
Please post any possible bugs you guys find.
Comment