Skip to main content
Version: Next

String To Datetime

Converts a string to a datetime using provided format

Description

Converts a string to a datetime using the provided <a href="https://date-fns.org/v2.29.3/docs/parse/" target="_blank">format</a>.

Examples:

  • "2010-10-20 04:30:22" can be parsed using format "yyyy-MM-dd HH:mm:ss"
  • "2024-05-29T00:00:00.000Z" can be parsed using format "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"

Inputs

  • dateTimeString (String): A string containing a date and/or time. Example: 2010-10-20 04:30:22
  • format (String): <a href="https://date-fns.org/v2.29.3/docs/parse/" target="_blank">Format</a> to be used to interpret dateTimeString. Example: yyyy-MM-dd HH:mm:ss

Outputs

  • date (DateTime): The result of the conversion.