suttercain Posted July 1, 2007 Share Posted July 1, 2007 Hello, There is a form on a clients page that allows the user to enter a date in the following format: March 3, 2007 Is it possible to convert that single single string into: 2007-03-03 Thanks for your help. PS. I tried strtotime with no luck. Link to comment https://forums.phpfreaks.com/topic/57923-solved-is-this-possible-june-13-2007-to-mysql-date/ Share on other sites More sharing options...
pocobueno1388 Posted July 1, 2007 Share Posted July 1, 2007 Does it allow them to put the date like that by a text input, or a select input? It will be a lot easier if you say "select input", but if not...we can work that out too. EDIT: By "select input" I mean something like this: <select name="month"> <option>January</option> <option>Feburary</option> <option>March</option> </select> ...and so on Then the same thing for the month/year. Link to comment https://forums.phpfreaks.com/topic/57923-solved-is-this-possible-june-13-2007-to-mysql-date/#findComment-287026 Share on other sites More sharing options...
suttercain Posted July 1, 2007 Author Share Posted July 1, 2007 It allows them to enter the date in a text input form. There are no drop downs. My client want to enter the date as such: April 2, 2007 I know, I know... I would have used do downs if I could have. Anyone know if this is possible? Thanks. I was thinking maybe explode??? Link to comment https://forums.phpfreaks.com/topic/57923-solved-is-this-possible-june-13-2007-to-mysql-date/#findComment-287029 Share on other sites More sharing options...
corbin Posted July 1, 2007 Share Posted July 1, 2007 $in = 'April 2, 2007'; $timestamp = strtotime($in); echo date('Y-m-d', $timestamp); //2007-4-2 Link to comment https://forums.phpfreaks.com/topic/57923-solved-is-this-possible-june-13-2007-to-mysql-date/#findComment-287033 Share on other sites More sharing options...
suttercain Posted July 1, 2007 Author Share Posted July 1, 2007 so that's how you do it. Thanks corbin! Link to comment https://forums.phpfreaks.com/topic/57923-solved-is-this-possible-june-13-2007-to-mysql-date/#findComment-287034 Share on other sites More sharing options...
pocobueno1388 Posted July 1, 2007 Share Posted July 1, 2007 Wow...I guess it isn't a pain after all. I didn't know PHP could work with written months, I guess I was wrong =] Link to comment https://forums.phpfreaks.com/topic/57923-solved-is-this-possible-june-13-2007-to-mysql-date/#findComment-287035 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.