useDateFormatter React Hook
Sources:
title: Contents
style: nestedList # TOC style (nestedList|inlineFirstLevel)
minLevel: 1 # Include headings from the specified level
maxLevel: 4 # Include headings up to the specified level
includeLinks: true # Make headings clickable
debugInConsole: false # Print debug info in Obsidian console
Overview
useDateFormatter
wraps a builtin browser Intl.DateTimeFormat object to provide a React Hook that integrates with the i18n system in React-Aria. It handles formatting dates for the current locale, updating when the locale changes, and caching of date formatters for performance. See the Intl.DateTimeFormat docs for information on formatting options.
Code Snippet
import { I18nProvider, useDateFormatter } from 'react-aria';
function CurrentDate() {
let formatter = useDateFormatter();
return <p>{formatter.format(new Date())}</p>;
}
<>
<I18nProvider locale="en-US">
<CurrentDate />
</I18nProvider>
<I18nProvider locale="ru-RU">
<CurrentDate />
</I18nProvider>
</>
Details
About
This note is about …
See Also
- JavaScript Map of Content
- JavaScript Code
- Hyper Text Markup Language (HTML)
- Cascading Style Sheets (CSS)
- React.js
- Next.js
Appendix
Note created on 2024-04-15 and last modified on 2024-04-15.
Backlinks
LIST FROM [[TS - useDateFormatter React Hook]] AND -"CHANGELOG" AND -"04-RESOURCES/Code/TypeScript/TS - useDateFormatter React Hook"
(c) No Clocks, LLC | 2024