Page 1 of 1

Manipulating Dates & Times

Posted: Thu May 03, 2018 11:08 am
by montyonthebonty

I'm trying to produce a basic time-sheet from a list of duties stored in MySQL table. Both 'bookedOn' and 'bookedOff' fields are date-time (to cater for turns that finish after midnight.

So far, I have the following code:

Code: Select all

			echo '<tr><td>'. date("Y:m:d", ($row["bookedOn"])) .  '</td>';

			echo '<td>'. date("H:i", strtotime($row["bookedOn"])) .  '</td>';

			echo '<td>'. date("H:i", strtotime($row["bookedOff"])) .  '</td>';

			echo '<td>'. date("H:i", strtotime(($row["bookedOff"] - $row["bookedOn"]))) .  '</td>';
The booked on and booked off times seem to be displaying the correct times. The first line seems to give a completely irrelevant date and the fourth line (which is supposed to be hours worked) seems to display something different altogether!

Any ideas why?


Re: Manipulating Dates & Times

Posted: Thu May 03, 2018 2:25 pm
by chorn
Your code is incomplete, provide example data.