Ponel Posted May 21, 2021 Share Posted May 21, 2021 (edited) PHP date and time function is not showing correct time on my local system I have the following php code date_default_timezone_set("Africa/Lagos"); $date = date('d-m-y h:i:s'); echo "Server Time ".$date ."<br>"; echo "The time is " . date("h:i:sa")."<br>"; $current_datetime = date("Y-m-d") . ' ' . date("H:i:s", STRTOTIME(date('h:i:sa'))); echo "Current time1: ".$current_datetime . "<br>"; Output Server Time 21-05-21 09:55:39 The time is 09:55:39am Current time1: 2021-05-21 09:55:39 Expected Output Server Time 21-05-21 10:55:39 The time is 10:55:39am Current time1: 2021-05-21 10:55:3 Any help would be appreciated. Edited May 21, 2021 by Ponel Quote Link to comment https://forums.phpfreaks.com/topic/312757-php-date-and-time-function-is-not-showing-correct-time-on-my-local-system/ Share on other sites More sharing options...
requinix Posted May 21, 2021 Share Posted May 21, 2021 Either (a) you're not in Africa/Lagos, which would be a silly mistake to make, (b) your timezone database is out of date, but probably not given that Africa/Lagos doesn't do DST, and/or (c) your server's clock is set incorrectly. Quote Link to comment https://forums.phpfreaks.com/topic/312757-php-date-and-time-function-is-not-showing-correct-time-on-my-local-system/#findComment-1586704 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.