This is a strange problem
I am using date functions to get time too but it returns wrong time
return date('Y-m-d H:i:s');
This returns 2017-4-21 09:41:44
but the current time is 14:41:44
There is something wrong with hours
.
I tried NOW()
in MySQL and it gave me correct timing but laravel PHP did not. Can someone help?
If you want to keep a new time zone for all future requests, you need to use a package like larapack/config-writer to be able to save the time zone to the app config file. Another way to handle this is to keep time zone in DB, fetch it in every request and set it with config(['app. timezone' => $timezone]) dynamically.
Based on reading your question and your comments below I would check the following. Make sure that /storage folder exists and that it has proper folder permission you can use 777 for testing, but make sure to change it when you are done. To do this type sudo chmod 0777 -R /storage when inside root.
In laravel project go to project/config
there is a file app.php
, in this file search for:
'timezone' => '';
pass your timezone value in it like:
'timezone' => 'Asia/Kolkata', // I am using this for India
And try again, now you will get the correct time as per your timezone.
Note: After passing the timezone value run the command php artisan config:cache
to clear the cache so that you get the updated data.
Timezone list reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With