Make WordPress Core

Opened 7 weeks ago

Last modified 7 weeks ago

#63493 new defect (bug)

Timezone string doesn't return in REST API /wp-json/wp/v2/settings

Reported by: phakphumvis's profile phakphumvis Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: REST API Keywords: has-patch needs-test-info needs-unit-tests close
Focuses: rest-api Cc:

Description

Timezone string in REST API /wp-json/wp/v2/settings always return as an empty string even set any timezone from Admin panel -> Settings.

Change History (7)

This ticket was mentioned in PR #8845 on WordPress/wordpress-develop by @nikunj8866.


7 weeks ago
#1

  • Keywords has-patch added

#2 @nikunj8866
7 weeks ago

  • Keywords needs-test-info needs-testing added

#3 @opurockey
7 weeks ago

timezone string return empty value if you set manual offsets value ( e.g.: UTC -12 ) from Settings->General->Timezone. Better use wp_timezone_string() if timezone value is found empty when using the /wp-json/wp/v2/settings endpoint.

#4 @nikunj8866
7 weeks ago

  • Keywords needs-unit-tests added

@opurockey Thanks for the feedback! I’ve revised the code based on your suggestion.

#5 @rmccue
7 weeks ago

This behaviour is intentional; if the timezone is set via gmt_offset, we want to clearly convey this to clients, rather than a potentially inaccurate timezone.

For example, if the site is set to UTC+1, that would currently (with DST) map to Europe/London, but during winter would map to Europe/Paris. We cannot disambiguate between these, so providing that information clearly to clients is intentional.

#6 @swissspidy
7 weeks ago

  • Keywords close added

Agreed with the above. That's why clients like Gutenberg check for both settings. i.e. if there's no timezone string, one should fall back to the offset.

#7 @SirLouen
7 weeks ago

  • Keywords needs-testing removed
Note: See TracTickets for help on using tickets.