freezer
freezer

Reputation: 541

What way is better to use date with timzone for clients

I am bulding a component for joomla which has announcements for others. And that announcements have creation date and date for its events. My clients can be in different countries. One can be in two countries in two different moment. So his timezone should be dynamic I think. which way is better to set the creation date and event date for this type of problem.

Upvotes: 1

Views: 95

Answers (3)

Elin
Elin

Reputation: 6770

Joomla handles that automatically as along as you don't store as anything but UTC.

Upvotes: 2

Anton
Anton

Reputation: 4018

You should ALWAYS store data in UTC (GMT) time, ideally in the form of a Unix timestamp. This is a standard that is not subject to any type of Daylight Savings Time changes and is perfect for saving a constant point in time.

Then, when displaying the date and time to an individual user, you can convert that timestamp into their local date and time.

Upvotes: 0

Zathrus Writer
Zathrus Writer

Reputation: 4331

I would always save datetime in GMT and display it on PHP side as required, based on the timezone you can get from that user's browser header, IP address or some profile setting.

Even if the client is in 2 different timezones, you should be able to track on which browser (from which timezone) they're viewing the page this way.

Upvotes: 0

Related Questions