Can someone tell me how to convert a date such as 8/13/10 into the the MySQL format, such as 2010-08-13 and also the reverse using PHP? I can't seem to find the right functions.
Thanks!
PHP Date Conversion
Moderator: General Moderators
- arrielmabale
- Forum Newbie
- Posts: 15
- Joined: Fri Aug 13, 2010 3:57 pm
- Location: Dubai
Re: PHP Date Conversion
//convert to sql
$mDate = 8/13/10
$edate = explode('/',$mDate);
$toSql = '20' + $edate[2] + '-' + $edate[1] + '-' + $edate[0];
##############
//from sql make sure to used UNIX_TIMESTAMP on the field
//then top display
$mdate = date('y/m/d');
i did not see the output, but im sure of this
$mDate = 8/13/10
$edate = explode('/',$mDate);
$toSql = '20' + $edate[2] + '-' + $edate[1] + '-' + $edate[0];
##############
//from sql make sure to used UNIX_TIMESTAMP on the field
//then top display
$mdate = date('y/m/d');
i did not see the output, but im sure of this
-
webphotogeek
- Forum Newbie
- Posts: 18
- Joined: Sun Jul 04, 2010 12:11 pm
Re: PHP Date Conversion
Thanks for the reply. I didn't think of using the explode function 
Re: PHP Date Conversion
Code: Select all
$mDate = "8/13/10";
$toSql = DateTime::createFromFormat("m/d/y", $mDate)->format("Y-m-d");