0

I need to create entries with dates and times based upon the timezone they are occurring in and then display them to the user on the front end with all dates/times in both event date/time and a localised date/time.

Is this possible with ExpressionEngine and if so how should I best approach it?

Edit

So it looks like the only real option is to standardise all dates/times entered via the CMS to UTC/GMT and use the users timezone preference to display the dates/times relative to where they are...

OR

Add a custom field that specifies timezone for an event and then offset the display date/time accordingly on the front end using a custom plug-in.

Any other thoughts?

1 Answer 1

0

If you store all entry dates as UTC you could manipulate what is displayed to the user by using Javascript to detect their timezone offset and adjust your date/time accordingly.

To get the time zone offset you can use the getTimezoneOffset() method of the Date() object in Javascript.

IMHO the only even remotely reliable way to do it is by looking at the user's browser. Of course, you are relying on them having it set correctly in the first place!

It kind of depends on how much you want to use a client side vs a server side approach.

4
  • Thanks - I was considering writing a plug-in infer their timezone from location using an IP address lookup but as you say something like this will not be at all reliable. I guess I could also ask them to specify their timezone at the point of registration as I think EE automatically adjusts dates/times to a users timezone when that's the case. :) Commented Jun 21, 2013 at 10:26
  • Stumbled across this subsequent to your suggestion; bitbucket.org/pellepim/jstimezonedetect - looks like it could be handy. :) Commented Jun 21, 2013 at 10:28
  • Yes you can use EE's built in localisation settings. That would be an option if you can get them set
    – foamcow
    Commented Jun 21, 2013 at 10:28
  • yup, I think that combined with a country/timezone field at registration (solspace.com/docs/user/edit/#user_timezone_menu) will do it. :) Commented Jun 21, 2013 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.