WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#24730 new enhancement

Introduce a timezone-retrieval method

Reported by: rmccue Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Date/Time Keywords: has-patch
Focuses: Cc:

Description

When working with times and dates, it's useful to have the timezone used in WordPress, however there's no unified way to get it.

get_option('gmt_offset') is filtered and the current offset is translated from the timezone string, but there's no reverse which is needed when working with relative times and dates.

There are two ways we could handle this:

  1. Filter timezone_string and work out the correct string - This will likely break the admin interface for it.
  2. Introduce a new function to get the timezone from timezone_string, and fall back to gmt_offset if needed.

Patch has implementation of the second option (also using DateTimeZone), can be adapted as necessary for the first.

Attachments (1)

24730.diff (983 bytes) - added by rmccue 4 years ago.
Add a wp_get_timezone() function

Download all attachments as: .zip

Change History (5)

@rmccue
4 years ago

Add a wp_get_timezone() function

#1 @johnbillion
4 years ago

  • Cc johnbillion added

#2 @mordauk
4 years ago

  • Cc pippin@… added

This ticket was mentioned in Slack in #core-restapi by joehoyle. View the logs.


3 years ago

#4 @rmccue
3 years ago

Related: #24730

Note: See TracTickets for help on using tickets.