Sample code for 30+ languages & platforms
Tcl

Extract Timestamp from ULID

See more ULID/UUID Examples

Extract the date/time from a ULID.

Important: Chilkat's ULID functionality was introduced in v9.5.0.94.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set ulid "01GRH14AA82EY9A7S99YYF2QDY"

set dt [new_CkDateTime]

# Unix timestamps stored in ULIDs should be UTC...
set bLocal 0
# Set the CkDateTime from the timestamp contained in the ULID
set success [CkDateTime_SetFromUlid $dt $bLocal $ulid]
if {$success == 0} then {
    puts "ULID was not valid."
    delete_CkDateTime $dt
    exit
}

# You can now get the date/time in any desired format.
# For example:
puts "Unix timestamp = [CkDateTime_GetAsUnixTime $dt $bLocal]"
puts "RFC822 = [CkDateTime_getAsRfc822 $dt $bLocal]"
puts "Timestamp = [CkDateTime_getAsTimestamp $dt $bLocal]"

# Sample output:

# Unix timestamp = 1675608861
# RFC822 = Sun, 05 Feb 2023 14:54:21 GMT
# Timestamp = 2023-02-05T14:54:21Z

delete_CkDateTime $dt