简体   繁体   中英

php convert date value preferred to mysql date

I have get data from oracle database and date value kept on 27-MAY-09. I need to insert this value to mysql database via PHP. I need to convert date format as 2009-05-27.

Any one know about it please let me know correct php statement for do this.

use date() function

$date = '27-MAY-09';
$newData = date('Y-m-d', strtotime($date));  

php fiddle

$date = DateTime::createFromFormat('j-M-y', $inputDate);
$newDate = $date->format('Y-m-d');

PHP 5.3 not earlier.

try this

$date1 = "27-MAY-09";
$data2 = date("Y-m-d",strtotime($date1));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM