Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nscherneck's avatar

Timezone conversions

Pretty sure this is a noob question, but I've got a bit of a bug I'm trying to work out. My understanding is that it's best to save dates in UTC and convert to a user's timezone where necessary.

In development (Homestead running locally) my models are saving to my database in UTC time (created_at), but in production (Digital Ocean) they're saving at local time (America/Los_Angeles).

config/app.php...

    'timezone' => 'UTC',

I also ran dpkg-reconfigure tzdata and set to local timezone and again to go back to UTC with, but no change. Is there somewhere else I should be looking?

FYI, my VPS is running Ubuntu 16.04, nginx, PHP-7.0.8, mysql

0 likes
2 replies
jekinney's avatar

You also need to make sure it's set to UFC time in the php.ini. Also make sure os time date is set properly. Otherwise it can't calculate proper utc.

nscherneck's avatar

@jekinney, I hadn't changed the timezone in php.ini. Changed it, restarted php and nginx but no change.

Please or to participate in this conversation.