FormatDateTime

Formats a timestamp into a date/time string.

Syntax

FormatDateTime(value: number, mode: number = TIME_DATE | TIME_MINUTES): string

Parameters

  • value: number - The Unix timestamp to format

  • mode: number - The format flags controlling the output

Return Value

Returns a string representing the formatted date and/or time.

Description

The FormatDateTime method converts a Unix timestamp into a formatted date/time string. The output format is controlled by the mode parameter, which can be a combination of the following flags:

TIME_DATE = 1 // Include date component (YYYY.MM.DD)
TIME_MINUTES = 2 // Include time with minutes (HH:MM)
TIME_SECONDS = 4 // Include seconds (SS)

The flags can be combined using the bitwise OR operator (|) to get different combinations of components.

Example

Format Specifications

  1. Date format: "YYYY.MM.DD"

    • YYYY: 4-digit year

    • MM: 2-digit month (01-12)

    • DD: 2-digit day (01-31)

  2. Time format: "HH:MM" or "HH:MM:SS"

    • HH: 2-digit hour (00-23)

    • MM: 2-digit minutes (00-59)

    • SS: 2-digit seconds (00-59) if TIME_SECONDS flag is set

Last updated