I have a datetime in the following String format:
/Date(1084640400000+0700)/
and I want to convert in format yyyy-mm-dd
to insert and update MySQL
by php.
Please recommend how do it.
I have a datetime in the following String format:
/Date(1084640400000+0700)/
and I want to convert in format yyyy-mm-dd
to insert and update MySQL
by php.
Please recommend how do it.
<?php
$timestamp=1084640400000+0700;
echo gmdate("Y-m-d\TH:i:s\Z", $timestamp);
?>
Now i have solution this
$str = $strDate;
$match = preg_match('/\/Date\((\d+)([-+])(\d+)\)\//', $str, $date);
print_r($date);
$timestamp = $date[1]/1000;
$operator = $date[2];
$hours = $date[3]/100*3600;
//$hours = substr($date[3],0,-2); // Get the seconds
// echo "<br/>".$hours."<br/>";
//print_r($timestamp);
$datetime = new DateTime();
$datetime->setTimestamp($timestamp);
$datetime->modify($operator . $hours . ' seconds');
var_dump( $datetime->format('Y-m-d H:i:s'));