Date and time formatting
const formatDate = function (date) {
  const options = {
    dateStyle: "full",
    timeStyle: "medium",
  }
  if (typeof date === "string") {
    date = new Date(date)
  }
  return date.toLocaleString("en-EN", options)
}

Date and time formatting

  • Files
  • Index
  • Style
  • Script
  • README
  • CDN Add
HTML

Date and time formatting without external library

Options

dateStyle

The date formatting style to use when calling format(). Possible values include:

  • full
  • long
  • medium
  • short

timeStyle

The time formatting style to use when calling format(). Possible values include:

  • full
  • long
  • medium
  • short

For more information visit https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat

PLEASE WAIT...