I'll try format datetime like this Thu Jun 15 2017 14:12:28 GMT 0700 (SE Asia Standard Time)
to format like 2017-06-5
in PHP. I use date_create
but have errorl like this
Warning: date_format() expects parameter 1 to be DateTimeInterface, string given
and this my PHP code
$aa = date_format($w22,"Y-m-d");
echo $aa;
content from $22 is Thu Jun 15 2017 14:12:28 GMT 0700 (SE Asia Standard Time)
how to format datetime like mine, please help me to solved my problem. Thanks
You need to remove GMT 0700 (SE Asia Standard Time)
$w22 = date_create("Thu Jun 15 2017 14:12:28")
$aa = date_format($w22,"Y-m-d");
echo $aa;
<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone
$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
$today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o
\t\h'); // 17:03:18 m is month
$today = date("H:i:s"); // 17:16:18
$today = date("Y-m-d H:i:s"); // 2001-03-10 17:16:18 (the
MySQL DATETIME format)
?>