I have a question for everyone to think about. I've posted some code below. Here is the situation... You have a server that is hosted in some unknown timezone. This was the only way I knew possible to always return the current time in the Eastern Timezone (or which ever one you program). Are there any other ways to do this? I don't have root access to the server so I think this is the best way. Let me know if you have any ideas! I look forward to hearing from you.
<?
$sql = "select year(curdate())";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$year = $row['year(curdate())'];
//echo $year;
$march = 14 - (floor(1 + $year * 5 / 4) % 7);
$november = 7 - (floor(1 + $year * 5 / 4) % 7);
//echo $march;
//echo $november;
$dst_starts = mktime(2, 0, 0, 3, $march, $year);
$dst_ends = mktime(2, 0, 0, 11, $november, $year);
//echo $dst_starts;
//echo $dst_ends;
$sql = "select unix_timestamp(utc_timestamp())";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
$dt = $row['unix_timestamp(utc_timestamp())'];
//echo $dt;
if( ($dt >= $dst_starts) && ($dt <= $dst_ends) ){
// DST is in effect (Eastern time zone = UTC -04:00)
$newtime = $dt - (3600 * 4);
}else{
// DST is NOT in effect (Eastern time zone = UTC -05:00)
$newtime = $dt - (3600 * 5);
}
//echo $newtime;
$format = "Y-m-d H:i:s";
$datetime = date($format, $newtime);
echo $datetime;
?>