Skip to content
Advertisement

Why does it display the wrong date in php

Note: Please don’t mark this as duplicate This is not related to other questions as they all have incorrect timezone while I don’t and the time getting displayed is literally January 01, 1970, 05:00:00 although it is May 19, 2020, 12:19:00 right now.

I am using the PHP date function for this

<?PHP

    date_default_timezone_set("Asia/Karachi");

    // Converting $timestamp to human readable format
    $date = date("F d, Y h:i:s", $timestamp);

?>

Advertisement

Answer

If you don’t include $timestamp it will give you the current date, which is what you want I assume:

$date = date("F d, Y h:i:s");

See the manual for more details.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement