Skip to content

Instantly share code, notes, and snippets.

@goofballLogic
Last active October 28, 2021 17:48
Show Gist options
  • Save goofballLogic/e98f720044b10ba9b41c46413a568b6b to your computer and use it in GitHub Desktop.
Save goofballLogic/e98f720044b10ba9b41c46413a568b6b to your computer and use it in GitHub Desktop.
import { OrdinalFormat } from "./ordinal-formatting.js";
const fullFormat = new Intl.DateTimeFormat("en", { dateStyle: "full" });
const now = new Date();
const parts = fullFormat.formatToParts(now);
const weekDayName = parts.find(p => p.type === "weekday").value;
const dayName = parts.find(p => p.type === "day").value;
const dayWithSuffix = new OrdinalFormat("en").withOrdinalSuffix(Number(dayName));
`${weekDayName} ${dayWithSuffix}` // Thursday 28th
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment