PHP date function giving wrong time [solved]
I can't get the PHP date function to give me the proper time. It is always a 4 hours and ahead.
I have set the date.timezone = "America/Toronto" and phpinfo() shows that it is set to that. The default timezone is set to UTC and I don't know how to change that as there isn't a variable for it in php.ini file.
This isn't just happening with Laragon it is also happening on my server. Laragon is running PHP 7.1 and my server is 7.2. I am using php-fpm on my server. I am not sure what Laragon uses.
Using nginx on my server and Laragon shows both Apache and Ngnix when starting.
@drdan : Can you show a sample code and your expected result?
Open config/app.php, then find
'timezone' => 'UTC'and change it to
'timezone' => 'America/Toronto'.
Please tell us the result.
Thanks guys. You both hit on my problems.
'timezone' => 'America/Toronto'in the config/app.php file was the solution.
I didn't mention it but the time was also off by a fraction of an hour rather than exactly 4 hours. This was caused by using m for minutes in the date function rather than i. Thus I was displaying the month not the minutes.
It is all good now. Thanks again.
@leokhoa hi Leo, how to change timezone in Laragon?
my php time() function return wrong time.
at php info, it show UTC timezone.
how can I change it to Indonesia (Jakarta) / UTC+7 timezone?
i can't find config/app.php mentioned in this thread.
@rustadelo : You can change it in your php.ini (Menu > PHP > php.ini)