Format date in PHP MMddyyyyHHmmss to m-d-y

219 Views Asked by At

Date Format using PHP

Input date is '1568145593000', i need to convert into m-d-y format using php

Anyone knows how to convert this? Thanks =).

1

There are 1 best solutions below

0
whoshotdk On BEST ANSWER
echo date('m-d-Y', 1568145593000 / 1000);

Divide the timestamp by 1000 to get the timestamp in seconds.

See:

PHP date https://www.php.net/manual/en/function.date.php and for the formatting characters: https://www.php.net/manual/en/datetime.format.php (scroll down a bit)