kreut Posted March 20, 2011 Share Posted March 20, 2011 Hello! A user is going to input a date in the form "mm/dd/yyyy". I'd like to convert this to a time stamp so that I can store it via MySql. I've heard about the "strtotime" function in PHP but I'm not sure how it can tell that the user 03/04/2011 represents March,4th 2011 and not, say April,3rd 2011 (European version). Help with the correct syntax for conversion would be greatly appreciated. Thank you, Eric Quote Link to comment Share on other sites More sharing options...
harristweed Posted March 20, 2011 Share Posted March 20, 2011 To be sure which date format is intended, use a date picker for the input...http://jqueryui.com/demos/datepicker/ Quote Link to comment Share on other sites More sharing options...
kreut Posted March 20, 2011 Author Share Posted March 20, 2011 Thank you for the response. I am actually using the datepicker; my question is how does php know which form I'm using if I do strtotime using php to turn it into a timestamp? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 21, 2011 Share Posted March 21, 2011 Why would you need to do that? If it's going into a MySQL database, you should be able to set up the datepicker so it sends the date pre-formatted as YYYY-MM-DD in the $_POST array. Then all you have to do is validate it and insert it. Quote Link to comment Share on other sites More sharing options...
jcbones Posted March 21, 2011 Share Posted March 21, 2011 Accepted strtotime() formats Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.