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. Quote Link to comment 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. Quote Link to comment 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??? Quote Link to comment 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 Quote Link to comment 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! Quote Link to comment 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 =] 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.