phpmysqldatestr-to-date

Format date in PHP MMddyyyyHHmmss to m-d-y


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 =).


Solution

  • 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)