formatDateTime | WebHare Platform SDK
WebHare Platform SDK
    Preparing search index...

    Function formatDateTime

    • Returns a string containing a formatted date and time.

      Parameters

      • format: string

        A string that specifies the format of the output string. The string can contain the following: %% Character % %a Abbreviated weekday name %A Full weekday name %b Abbreviated month name %B Full month name %d Two-digit day of month (01 - 31) %#d Two-digit day of month, remove any leading zeros %H Hour of the day, 24 hour day %#H Hour of the day, 24 hour day, remove any leading zeros %I Two-digit hour, 12 hour day (01 - 12) %#I Two-digit hour, 12 hour day, remove any leading zeros %j Three-digit day of year (001 - 366) %#j Three-digit day of year, remove any leading zeros %m Two-digit month number (01 - 12) %#m Two-digit month number, remove any leading zeros %M 2-digit minute (00 - 59) %#M 2-digit minute, remove leading any zeros %Q Three-digit millisecond (000-999) %#Q Three-digit millisecond, remove any leading zeros %p AM or PM %S Two-digit second (00 - 59) %#S Two-digit second, remove leading any zeros %V Two-digot week number (00 - 52) %#V One-digit week number (0 - 52) %y Two-digit year without century (00 to 99) %#y Two-digit year without century, remove any leading zeros %Y Year with century %#Y Year with century, remove any leading zeros

      • zdt: ZonedDateTime

        The date/time value to format.

      • Optionaloptions: { locale: string }

      Returns string

      // The current date and time in German in the format: 01 Januar 2005
      const example1 = formatDateTime("%d %B %Y", Temporal.Instant.now(), { locale: "de-DE" });

      // The current day of the week in the Dutch language, using the
      // parameter datetexts as language switch.
      // The date format is <abbreviated> - <full>.
      const example2 = formatDateTime("%a - %B ", new Date, { locale: "nl-NL" });