mubashir Posted October 26, 2007 Share Posted October 26, 2007 i hve a date variable in mm-dd-yyyy format how can i change it to mysql default format i.e., yyyy-mm-dd format ... Quote Link to comment https://forums.phpfreaks.com/topic/74884-changing-date-format/ Share on other sites More sharing options...
jeppers Posted October 26, 2007 Share Posted October 26, 2007 Show me your code Quote Link to comment https://forums.phpfreaks.com/topic/74884-changing-date-format/#findComment-378610 Share on other sites More sharing options...
premiso Posted October 26, 2007 Share Posted October 26, 2007 www.php.net/strtotime www.php.net/date <?php $date = "01-01-2007"; $tstamp = strtotime($date); $newdate = date("Y-m-d", $tstamp); echo $newdate; ?> Quote Link to comment https://forums.phpfreaks.com/topic/74884-changing-date-format/#findComment-378613 Share on other sites More sharing options...
rajivgonsalves Posted October 26, 2007 Share Posted October 26, 2007 or use the mysql function STR_TO_DATE example STR_TO_DATE( '07/31/2007', '%m/%d/%Y' ) Quote Link to comment https://forums.phpfreaks.com/topic/74884-changing-date-format/#findComment-378619 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.