WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#6285 closed enhancement (duplicate)

Choose timezone without doing math

Reported by: markjaquith Owned by: jacobsantos
Milestone: Priority: low
Severity: minor Version: 2.5
Component: Administration Keywords:
Focuses: Cc:

Description

Now that we have timezone offsets hardcoded (dropdown list), we could now take things a step further and allow people to choose their local time from the dropdown.

Current:

  1. Look at UTC.
  2. Look at current time
  3. Calculate difference
  4. Find that difference in the dropdown list

Proposed:

  1. Look at current time
  2. Find that time in the dropdown list

I actually started coding this at one point, but was bamboozled by the plethora of crazy one-quarter timezone offsets in the world. But now that's how we're doing that, it seems to be an idea worth proposing.

Change History (16)

comment:1 @Viper007Bond7 years ago

We should also consider a JS solution. Perhaps an "automatic" link/checkbox to the right of the dropdown that when clicked, auto-selects an item from the dropdown and records which user selected that. Then, when that user comes back, it makes sure the time is still correct (i.e. DST).

vBulletin for example auto-corrects for DST based on your PC's clock. Incredibly handy.

comment:2 @Otto427 years ago

It would be nice if we could get away from the manual offset entirely and start using the built in timezone functionality to PHP. I'd much rather choose "America/Chicago" from a dropdown list than to figure out that I'm UTC-6 or UTC-5 depending on the time of the year.

This would mean requiring PHP5, admittedly.

comment:3 @Viper007Bond7 years ago

-1, kinda, to Otto's suggestion. I prefer the offset behind shown, but I'd love to see a list of major cities following that.

Listing cities only drives me nuts as no two lists ever have the same list of cities, so I spend a bunch of time looking for a city in my timezone since they're listed alphabetically.

comment:4 @ffemtcj7 years ago

Maybe use the same list that the servers use.

comment:5 follow-up: @markjaquith7 years ago

Not really worth talking about things that require PHP5 until we're requiring PHP5 (and let's not discuss that here!!)

Viper007Bond's suggestion is interesting. I don't know if I'd want it to auto-correct -- what if you have authors from multiple time zones? But when viewing the options screen it could maybe offer you a "Sync to my computer's clock" option.

comment:6 in reply to: ↑ 5 @Viper007Bond7 years ago

Replying to markjaquith:

I don't know if I'd want it to auto-correct -- what if you have authors from multiple time zones?

Yeah, that's why if there was auto-sync after the initial sync, it'd have to be tied to a specific user (i.e. the owner of the blog or whoever picked the time).

comment:7 follow-up: @Otto427 years ago

Viper007: The city list is standardized, albeit updated every so often:
http://en.wikipedia.org/wiki/Zoneinfo
http://en.wikipedia.org/wiki/List_of_zoneinfo_timezones

What's more, PHP can even produce it on demand:
http://php.net/manual/en/function.timezone-identifiers-list.php

When it comes to timezones and handling daylight savings time, the zoneinfo method is the One True Way(tm).

However, after looking closely at 2.5's method of handling this, I believe this could be handled by a plugin in the right way. Essentially, I'd hook a filter onto the gmt_offset option, and replace it with the offset as calculated by the timezone functions (if they were available).

comment:8 in reply to: ↑ 7 @Viper007Bond7 years ago

Replying to Otto42:

What's more, PHP can even produce it on demand:
http://php.net/manual/en/function.timezone-identifiers-list.php

That requires PHP 5.1.0+. ;)

I was unaware of zoneinfo though, that may work nicely.

comment:9 @Otto427 years ago

To demonstrate how such functionality would work, I coded up a quick plugin. You can find it here:

http://ottodestruct.com/wpstuff/timezone.php

It requires PHP 5.1 or up. Features:

  • Won't activate if your version of PHP cannot support it (this could be prettier, admittedly).
  • If you have PHP 5.2 or up, it will give you extra information about when DST will start/end (needs the timezone_transitions_get function in 5.2 to work).
  • Overrides the gmt_offset entirely with a pre_option. You'll notice that when it's activated and set, you will be unable to change the offset setting and have it stick.

comment:10 @Otto427 years ago

Whoops. Sorry, the plugin is here:
http://ottodestruct.com/wpstuff/timezone.zip

Don't use this on a production system, mind you. It doesn't do many validity checks yet, just a nonce.

comment:11 @jacobsantos7 years ago

  • Owner changed from anonymous to jacobsantos

comment:12 @Otto427 years ago

I'm no longer convinced that this is possible in all cases, given our current low system requirements (PHP4 and such). For those cases where it does work, my plugin does the job: http://wordpress.org/extend/plugins/automatic-timezone/

Suggest this be put off until such time as the powers-that-be decide to rev up to a minimum requirement of PHP5. http://gophp5.org/

comment:13 follow-up: @ryan7 years ago

In this particular instance, I wouldn't mind putting a conditional on PHP 5.2 and supporting pretty timezones and DST and if we have 5.2 and doing what we currently do if < 5.2.

comment:14 in reply to: ↑ 13 @Otto427 years ago

Replying to ryan:

In this particular instance, I wouldn't mind putting a conditional on PHP 5.2 and supporting pretty timezones and DST and if we have 5.2 and doing what we currently do if < 5.2.

Well, that could indeed be done. I can pop out a patch here shortly, as I've already got that pretty code in a plugin, more or less. :)

comment:15 @Otto427 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Dupe of #3962

comment:16 @jacobsantos7 years ago

  • Milestone 2.9 deleted
Note: See TracTickets for help on using tickets.