0

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.

friedemann_bach
  • 1,418
  • 14
  • 29
TP.ARM
  • 9
  • 1
  • `date('Y-m-d', strtotime('1084640400000+0700'))` – Mohammad May 18 '17 at 08:21
  • 1
    Possible duplicate of [Convert one date format into another in PHP](http://stackoverflow.com/questions/2167916/convert-one-date-format-into-another-in-php) – Picard May 18 '17 at 10:28

2 Answers2

0
<?php
$timestamp=1084640400000+0700;
echo gmdate("Y-m-d\TH:i:s\Z", $timestamp);
?>
0

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'));
TP.ARM
  • 9
  • 1