time formatting

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

time formatting

Post by gurjit »

Hi all,

I have in a database times displayed like

"2:30 to 4:30"
"10:00 to 12:00"

all these times are daytime times and i need to manipulate the data so that i can represent the above into start and end times in 24 hour. so the above would be presented as:


start time
14:30
10:00

end time
16:30
12:00


How can i do this. I tried the following to represent 2:30 and it displays 02:30 and not 14:30:

Code: Select all

<?php

$timedd = &quote;2:30&quote;;

echo date(&quote;H:i&quote;, strtotime($timedd));

?>
any ideas how i can achieve this?
Bennettman
Forum Contributor
Posts: 130
Joined: Sat Jun 15, 2002 3:58 pm

Post by Bennettman »

$timedd should either be "14:30" or "2:30pm". As it is, PHP recognises it as 2:30 AM.
Post Reply