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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.