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! 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. 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 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
Archived
This topic is now archived and is closed to further replies.