Dev Helpers
← Back

Month length label

Import and render <MonthLengthLabel /> in a React project.

Open this example in the interactive library

Live preview

Source code

// components/MonthLengthLabel.tsx

export default function MonthLengthLabel({
  day = "2028-02-29",
}: { day?: string } = {}) {
  const d = new Date(day + "T00:00Z");
  return (
    <output>
      {new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + 1, 0)).getUTCDate()} days
      in this month
    </output>
  );
}