Jump to content

Suggestions please


dadamssg

Recommended Posts

hi,

Im creating a form where the user can enter in a date and time...say they want to enter Jan 3 2009 6:00 am. Keeping the php side of the form in mind and making it simple for the user to choose, i want to store their input in my database as datetime. Any suggestions on how i could do this in the form which wouldn't require a lot of manipulating variables to enter in the mysql database in the correct format for datetime to understand? ive thought about just creating a text field, but then drop down menus could make it easier but prolly more difficult to get in the right format. thanks

Link to comment
https://forums.phpfreaks.com/topic/140759-suggestions-please/
Share on other sites

strtotime might help you.  If it were entered in a working format, you could convert it to a unix timestamp and do anything from there.

 

 

I suggest figuring out someway to make sure the client enters the data as wanted though.  Perhaps a JS calendar or drop downs or something.

Link to comment
https://forums.phpfreaks.com/topic/140759-suggestions-please/#findComment-737486
Share on other sites

That's going to be difficult. Does 01-02-2009 mean January 2 or February 1, for instance? It'll be better to enforce a particular format.

 

 

Hrmmm true....  Wonder if PHP is locale specific when it comes to strtotime (I bet it is), because if so, it would decide differently on different servers.  Hrmmm...

Link to comment
https://forums.phpfreaks.com/topic/140759-suggestions-please/#findComment-737948
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.