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

somenet77's avatar

Timestamp for global event.

I am developing an event website where user from globally can add their event. So my issue is how to store an event date and time in the database. For example, if a user from the US added an event from the US then when a website visit from the US fetches data according to US timezone. Likewise, if an event is added for India then same as US and soon. Also how to configure schedule work so that users can get notifications before the event starts according to timezone.

0 likes
5 replies
nguyenhy's avatar

So, does this mean you should know what event user subscribe to and which timezone they expect it to start?

tykus's avatar

Store UTC datetime (converting from local if necessary) and always render in the user's local timezone.

somenet77's avatar

@tykus I have already stored datetime in utc. My issue is how to fetch and schedule to send notifications according to country timezone.

tykus's avatar

@somenet77 I must have misread this?

my issue is how to store an event date and time in the database.

The users' timezone is irrelevant to scheduling notifications; the datetimes for the events are stored using universal time, so whenever the schedule runs, you fetch the Events upcoming and notify the users.

martinbean's avatar

if a user from the US added an event from the US then when a website visit from the US fetches data according to US timezone

@somenet77 The U.S. has multiple timezones. There is no “US timezone”. For example, California has a completely different timezone (pacific) to say, New York (Eastern). There are then timezones in between (central, mountain) as well as special timezones for Hawaii and Alaska.

You’ll need to have the user select their timezone when creating the event. You can then convert from that timezone to UTC when saving to the database, and convert to that timezone (or any timezone) when displaying dates and times, i.e. in a form for editing the event or on your front-end.

If you store dates and times and UTC then that also removes the need for needing to know the timezone for things like scheduled tasks and notifications. You can just schedule your notification whenever; it doesn’t matter because if you’re using UTC then that date and time is absolute. An hour before the event is an hour before the event, no matter the timezone.

Please or to participate in this conversation.