DataSpy Posted February 13, 2012 Share Posted February 13, 2012 I'm trying to format a date to use in a mysql query and was wondering about the best way to do it. the form returns: mm/dd/yyyy and I need to format it to yyyy-mm-dd, any help would be greatly appretitaed, thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/257071-how-to-format-a-date/ Share on other sites More sharing options...
kicken Posted February 13, 2012 Share Posted February 13, 2012 Run it through strtotime to get a timestamp value, then use the date function to format it how you want. When you run it through strtotime you should check the result to ensure success, incase they enter a date it can't understand or is invalid. Quote Link to comment https://forums.phpfreaks.com/topic/257071-how-to-format-a-date/#findComment-1317815 Share on other sites More sharing options...
DataSpy Posted February 13, 2012 Author Share Posted February 13, 2012 thank you Quote Link to comment https://forums.phpfreaks.com/topic/257071-how-to-format-a-date/#findComment-1317831 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.