I'm trying to set the timezone for a date in a Carbon
object. It works fine locally but on my production box it keeps giving me Bad timezone
error.
I've tried:
$date->setTimezone('7');
$date->setTimezone('+7');
$date->setTimezone('7:00');
$date->setTimezone('+7:00');
$date->setTimezone('UTC 7');
$date->setTimezone('UTC +7');
$date->setTimezone('UTC 7:00');
$date->setTimezone('UTC +7:00');
No idea why it's complaining on my production box. Can't find documentation either on what is the "proper" format to enter here. Can someone please help.
FYI: local is windows, and prod is Ubuntu box.
$d = Carbon::now()->setTimezone(request_timezone());
This line: 1 it won't change timestamp (aka$d->getTimestamp();
is the same as$d2 = Carbon::now(); $d2->getTimestamp();
) 2 it works as it sets the timezone so that it can return the correct startOfDay() timestamp in that timezone aka YOUR_TZ 00:00's timestamp. (when not setting timezone and calls startOfDay(), it returns UTC 00:00's timestamp) – Fontes