How to Convert PHP Date Into Mysql Date Format in php? -
this question has answer here:
- convert 1 date format in php 12 answers
i have tried convert following date mysql date format
accutual date : 01-01-17
php code
<?php $datesrc = '01-01-17'; echo date('y-m-d', strtotime($datesrc)); ?>
result:
2001-01-17
in case how handle type of date format(01-01-17 (d-m-y)), because got date format in user uploaded file..
<?php $datestring = '01-01-17'; $mydatetime = datetime::createfromformat('d-m-y', $datestring); $newdatestring = $mydatetime->format('y-m-d'); echo $newdatestring;
?>
you can this. first use datetime::createformat create datetime instance of time trying convert use normal php format change the format want
ps. work if know format of date want convert
Comments
Post a Comment