[SOLVED] update query to time fields

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
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

[SOLVED] update query to time fields

Post by Burrito »

I have some fields of type: time in my MySQL db and I'm trying to update them with a sql query that I'm running on a form action page:

I've tried this:

Code: Select all

starttime = '".date("h:i a",strtotime($_POSTї'starttime']))."',
starttime = '".date("h:i a",strtotime($_POSTї'endtime']))."'
and this:

Code: Select all

starttime = '".date("G:i",strtotime($_POSTї'starttime']))."',

starttime = '".date("G:i",strtotime($_POSTї'endtime']))."'
but when something like "11:00 am" to "2:00 pm" gets entered it displays as 1:00 am.

I know I could check the string to see if it has am or pm in it and then convert it to a 24 hour format...but what's the fun in that??

shouldn't date() and strtotime() be doing this for me?

Burr
Post Reply