Issue with date funciton in PHP -
this question has answer here:
- convert 1 date format in php 12 answers
i have 1 issue date function below have put code. please check. have used jquery calender in joomla component
echo $data['startpublish']; $data['startpublish'] = date('y-m-d', strtotime($data['startpublish'])); echo "?>>>>>>>>>>>".$data['startpublish']; exit;
i have store date mm-dd-yy format. when store 01-02-2015 store data in db in (y-m-d) format , when store 01-28-2015 (28 janvary) convert 1970-01-01.
please let me know issue . have added both screenshot well.
issue ss : http://prntscr.com/812w0c
correct ss : http://prntscr.com/812xbj
this strtotime
quirk text date representation , american illogical way of saying/writing dates used in conversion having either -
or /
or .
seperators.
quote php manual, why did go there information wonder.
note:
dates in m/d/y or d-m-y formats disambiguated looking @ separator between various components: if separator slash (/), american m/d/y assumed; whereas if separator dash (-) or dot (.), european d-m-y format assumed.
so make american date format 01-28-2015
store have convert have /
seperators example
$data['startpublish'] = str_replace('-','/', $data['startpublish']); $data['startpublish'] = date('y-m-d', strtotime($data['startpublish'])); echo "?>>>>>>>>>>>".$data['startpublish'];
Comments
Post a Comment