@unikue/ts-lang-utils
    Preparing search index...

    Function toTimestamp

    • Converts a date or date string to a timestamp in milliseconds, returns undefined if invalid

      Parameters

      • Optionalvalue: string | Date | null

        The date or date string to convert

      Returns number | undefined

      the timestamp in milliseconds, or undefined if invalid

      David Hsing

      toTimestamp('2023-01-01');    // 1672531200000
      toTimestamp('invalid'); // undefined
      toTimestamp(new Date('2023-01-01')); // 1672531200000