Create mysql compatible Date from variables in PHP -
i have field set type date
in mysql table. day, month , year user , @ moment have values returned this:
[start_datemonth] => 08 //$stardmonth [start_dateday] => 7 //$startday [start_dateyear] => 2013 //$startyear
how can convert valid date can insert in database?
this own code, reasons browser shows blank screen no source code inside:
$format = 'y-m-d h:i:s'; $start = datetime::createfromformat($format, "$startyear-$startmonth-$startday $starthour:$startminutes:00"); echo $start;
from manual
although mysql tries interpret values in several formats, date parts must given in year-month-day order (for example, '98-09-04'), rather in month-day-year or day-month-year orders commonly used elsewhere (for example, '09-04-98', '04-09-98')
.dates containing two-digit year values ambiguous because century unknown. mysql interprets two-digit year values using these rules:year values in range 70-99 are converted to1970-1999.year values in range 00-69 are converted to2000-2069.
located here http://dev.mysql.com/doc/refman/5.5/en/date-and-time-types.html
or date("y-m-d")
if want generate php function
Comments
Post a Comment