I have a couple textboxes that allows a person to enter a time and date. The time is entered with a textbox for hours, a textbox for minutes, a drop down for am/pm and some drop downs for months/hours/years
So, I’d like to combine all of these to create a timestamp out of it and save it to the database.
But i’ve confused myself in how to do all that to create a proper timestamp, especially with the AM/PM part.
It sounds like you’d just use mktime(). Get the correct hour number by adding 12 for pm, then pass the arguments into the function.
If you’re looking for a MySQL timestamp instead of a UNIX timestamp, you have two options:
date('Y-m-d H:i:s', $time);UPDATE table SET date = FROM_UNIXTIME($time) WHERE foo='bar'Or you could just store the integer timestamp in the database as an integer.