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 Link to comment https://forums.phpfreaks.com/topic/231188-strtotime/ 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/ Link to comment https://forums.phpfreaks.com/topic/231188-strtotime/#findComment-1189946 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? Link to comment https://forums.phpfreaks.com/topic/231188-strtotime/#findComment-1190090 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. Link to comment https://forums.phpfreaks.com/topic/231188-strtotime/#findComment-1190099 Share on other sites More sharing options...
jcbones Posted March 21, 2011 Share Posted March 21, 2011 Accepted strtotime() formats Link to comment https://forums.phpfreaks.com/topic/231188-strtotime/#findComment-1190122 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.