Skip to content

Instantly share code, notes, and snippets.

@goofballLogic
Last active October 28, 2021 17:52
Show Gist options
  • Save goofballLogic/d838cd14b54f87e1736321a884d7b0b8 to your computer and use it in GitHub Desktop.
Save goofballLogic/d838cd14b54f87e1736321a884d7b0b8 to your computer and use it in GitHub Desktop.
const fullFormat = new Intl.DateTimeFormat("en", { dateStyle: "full" });
const now = new Date();
fullFormat.format(now);
// Thursday, October 28, 2021
fullFormat.formatToParts(now)
/*
[
{
"type": "weekday",
"value": "Thursday"
},
{
"type": "literal",
"value": ", "
},
{
"type": "month",
"value": "October"
},
{
"type": "literal",
"value": " "
},
{
"type": "day",
"value": "28"
},
{
"type": "literal",
"value": ", "
},
{
"type": "year",
"value": "2021"
}
]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment