I've recently upgraded to PHP5, and have noticied that within an application I've built there seems to be an extra hour added to some of my variables and caculations.
I am using:
date_default_timezone_set('Europe/London');
which I understand means that PHP is using BST opposed to standard GMT, but when I print empty variables (returned before as 00:00 using "H:i") - I'm now getting 01:00.
When caculating the hour/mins difference between two datetimes - I'm also getting an extra hour.
My basic code is:
<td><?php if(isset($item->start_time)) { echo date('H:i', strtotime($item->start_time)); } ?></td>
<td><?php if(isset($item->finish_time)) { echo date('H:i', strtotime($item->finish_time)); }?></td>
<td>
<?php
$start = strtotime($item->start_time);
$end = strtotime($item->finish_time);
$elapsed = $end - $start;
if($elapsed != NULL) { echo date("H:i", $elapsed); }
?>
</td>
Which for an example rown returns:
Start: 08:57 (Based on $item->start_time as 2011-03-19 08:57:23 in my DB)
Finish: 12:59 (Based on $item->finish_time as 2011-03-19 12:59:38 in my DB)
Caculation: 05:02 (This should be 04:02)