diff --git a/components/post-date/index.tsx b/components/post-date/index.tsx index 0a1707ef..edf36b7e 100644 --- a/components/post-date/index.tsx +++ b/components/post-date/index.tsx @@ -38,6 +38,12 @@ interface PostDateProps { */ format?: string; + /** + * The timezone to use for formatting. + * When not provided, dateI18n falls back to the WordPress site timezone. + */ + timezone?: string; + /** * Remaining props to pass to the time element. */ @@ -47,6 +53,7 @@ interface PostDateProps { export const PostDate: React.FC = ({ placeholder = __('No date set', 'tenup'), format, + timezone, ...rest }) => { const { postId, postType, isEditable } = usePost(); @@ -54,7 +61,6 @@ export const PostDate: React.FC = ({ const [date, setDate] = useEntityProp('postType', postType, 'date', postId as string); const [siteFormat] = useEntityProp('root', 'site', 'date_format'); const settings: DateSettings = getSettings(); - const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; const resolvedFormat = format || siteFormat || settings.formats.date; diff --git a/components/post-date/readme.md b/components/post-date/readme.md index accf1d71..65ace4ab 100644 --- a/components/post-date/readme.md +++ b/components/post-date/readme.md @@ -23,4 +23,5 @@ function BlockEdit() { | ---------- | ----------------- | -------- | -------------------------------------------------------------- | | `placeholder` | `string` | `No date set` | | | `format` | `string` | | Uses the WordPress date format setting of the site | +| `timezone` | `string` | | Uses the WordPress site timezone when not provided | | `...rest` | `object` | `{}` | |