Printing an East Coast Timestamp in Arizona time

Hello,

The code returns “datesubmitted” in a nice format. The field “datesubmitted” is a timestamp of East Coast time. How could I print it out as Arizona time? Right now, that would be 3 hours behind East Coast time.

For now, I would be happy just to do that. However, during other parts of the year (when Daylight Savings time is not being used), Arizona time is only 2 hours behind East Coast time. Is there a way that I could print the date below so that Arizona time is always correctly displayed? Or would I have to change the code when Daylight Savings time stops and starts?

Thanks in advance,

John

date('l, F j, Y &\
b\\sp &\
b\\sp g:i a &\
b\\sp &\
b\\sp  \\N\\E\\W &\
b\\sp \\Y\\O\\R\\K &\
b\\sp \\T\\I\\M\\E', strtotime($row["datesubmitted"]))

You could do something like this.



$tzFrom = new DateTimeZone('America/New_York');
$tzTo = new DateTimeZone('America/Phoenix');


$dt = new DateTime($row["datesubmitted"], $tzFrom);
$dt->setTimezone($tzTo);
echo $dt->format(DATE_RFC822);

I have a feeling though that your timestamp is in utc, not east coast time, in which case the tzFrom would be UTC

Thanks… I think this will help me. I’m trying to print dates out for dynamic results. Is there a way that I can combine all of this into one variable?

No, but you could write a function to do it.