Syed M. Sannan
Syed M. Sannan

Reputation: 1363

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

?>

Upvotes: 0

Views: 235

Answers (1)

GluePear
GluePear

Reputation: 7715

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.

Upvotes: 1

Related Questions