Manipulating Dates & Times

Codes here !

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 2
Joined: Thu May 03, 2018 11:05 am

Thu May 03, 2018 11:08 am


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?


php-forum Fan User
php-forum Fan User
Posts: 600
Joined: Fri Apr 01, 2016 2:18 am

Thu May 03, 2018 2:25 pm

Your code is incomplete, provide example data.

Post Reply