How to convert this time format - 1480550400000 + 0000 to Y / m / d date format using php

I am trying to convert this time format - 1480550400000+0000to Y/m/ddate format using php date('Y/m/d',1480550400000+0000); but it does not work. How can I make it work?

0
source share
5 answers

Solved, I just divided this by 1000. $ date = date ("Ymd", $ timestamp / 1000); and he worked

thank

0
source

The timestamp has microseconds, so delete it first.

<?php
$timestamp = 1480550400000+0000;
$timestamp = intval($timestamp/1000);
$date = date("Y/m/d", $timestamp);
echo $date;

conclusion: check out the live demo .

ei@localhost:~$ php test.php
2016/12/01
+1
source

, , Unix (1 1970 00:00:00 GMT). , .

PHP()

date ( $format [, int $timestamp = time()])

The optional timestamp parameter is an Unix integer timestamp that defaults to the current local time if no timestamp is specified. In other words, the default value is time ().

Try the following:

echo date('Y/m/d',1480550400+0000); // 2016/11/30
0
source
$dig_date= 1480550400000+0000;
$date = DateTime::createFromFormat('YmdGis', $dig_date);
  echo $date->format('Y-m-d G:i:s');
0
source

@Symplifys try the following:

<?php
    $date = date("Y-m-d", "1480550400000+0000");``
    echo $date;
?>

Remember to put the time stamp in double quotation marks.

Try this code at http://phpfiddle.org/

-1
source

Source: https://habr.com/ru/post/1673277/


All Articles