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

ralphmorris's avatar

Current timestamp show 1 hour behind. Forge, Digital Ocean

Wonder if somebody can help me?

How do I manage the timezone of a Forge, Digital Ocean server?

I have just noticed that when updating a row the update_at timestamp saves to one hour behind which on the messaging system is a bit of a problem. I tried restarting the server just incase it had got out of step but that didn't change anything.

How does this work with daylight saving? I need it to sync up to UK time.

https://www.timeanddate.com/time/zone/uk/london

Thanks in advance!

0 likes
3 replies
Cronix's avatar
Cronix
Best Answer
Level 67

It's a bit complicated, especially if you already have data in the db. Working with timezones can be a bit of a headache.

There is a timezone setting in app/config/app.php, which is set to UTC as default. Personally, that's what I use so all date/times in the database are using UTC.

When retrieving the dates/times from the db, I convert them to the users local timezone with carbon. created_at and updated_at are automatically converted to Carbon instances. You can add more fields in the $dates array of the model, if you have more custom date/time fields. My user table has a timezone field so they can set their local timezone (which does use daylight savings time if in effect for that tz).

So, for example, when outputting a date, I'd do something like: echo $MyModel->updated_at->setTimezone($user->timezone)->format('n/j/Y');

But my app supports people in many timezones. If your app is only working with a particular timezone and all of the users are in that same timezone, you could just change the timezone setting in the config file, however that would only affect newly added dates to the db. All the existing dates in your database would then need to be updated to the new timezone.

1 like
ralphmorris's avatar

Thanks @Cronix,

Your suggestion was really helpful.

My app is pretty much exclusively targeting Europe/London but who knows in the future so have kept the default setting UTC for saving to the db and have created a timezone field on the User model with a default of Europe/London which they can change in their account settings if needed.

Thanks @krekas also, I will look at installing ntp if the server clock starts to drift.

Please or to participate in this conversation.