Make WordPress Core

Opened 16 months ago

Last modified 16 months ago

#63493 new defect (bug)

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

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

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.


16 months ago
#1

  • Keywords has-patch added

#2 @nikunj8866
16 months ago

  • Keywords needs-test-info needs-testing added

#3 @opurockey
16 months 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
16 months ago

  • Keywords needs-unit-tests added

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

#5 @rmccue
16 months 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
16 months 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
16 months ago

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