Carbon now time wrong
This appears to be because the timezone of your server is different to your own.
This could be caused by:
- Server misconfiguration
- Physical location of the server is in a different timezone
- Policies of your provider could also cause this. If your provider decides they want to operate on the same timezone on every server they have throughout the world, this will cause issues.
The server's timezone appears to be CET (Central European Time) which is +1 GMT, as you described.
To fix this, you should change the timezone in your php.ini
file (instructions are from the link):
- Open your
php.ini
file - Add the following line of code to top of your php.ini file:
date.timezone = "US/Central"
Alternatively you should replace the US/Central
timezone with the desired timezone as outlined here if you wish PHP to use another timezone.
Carbon is UTC based therefore simply doing Carbon::now()
will output the time in UTC format
You have to specify the timezone for an accurate reflection of the dateTime in your city or area.
There are two ways to do this. You can either do:
Carbon::now('PST')
OR Carbon::now('Continent/City') like (Carbon::now('America/Montreal')
for example