Tech Tip: Utility Method to Extract UUID Version 7 Date and Time
PRODUCT: 4D | VERSION: 20 R10 | PLATFORM: Mac & Win
Published On: October 20, 2025
4D 20R10 introduces UUID version 7 which will include a timestamp into the generated UUID of the GMT date and time it was created. The time is a Unix Epoch Timestamp in milliseconds, which means it is the number of milliseconds since midnight January 1, 1970. This value is stored in the first 6 bytes or 48 bits of the UUID as a Big Endian value.
Below is a utiliy that will extract the time from a UUID created under the Version 7 standards:
The method takes in a UUID in text format. It will then convert the Big Endian Unix Epoch time to a decimal value. This will then allow the date and time the UUID was created, in GMT time, to be calculated.
Below is an example that should return the current time in GMT when executed:
Below is a utiliy that will extract the time from a UUID created under the Version 7 standards:
// Method: Util_GetUUID7DateTime // Reminder : Time is in GMT // Parameters: // $input - UUID in Text format // // Output: // $result - returns an object with the following date and time properties // - msUnixEpoch (Real) : Milliseconds since 1/1/1970 // - Date (Date) : Calculated Date // - TimeSeconds (Integer) : Time in seconds // - Timestamp (Text) : String Time stamp #DECLARE($input : Text)->$result : Object var $msEpoch : Real var $i; $msPerDay : Integer var $daysEpoch; $msRemainder : Integer $msEpoch:=0 For ($i; 0; 11) Case of : ((Character code($input[[12-$i]])>=48) && (Character code($input[[12-$i]])<=57)) $msEpoch+=Num($input[[12-$i]])*(16^$i) : ((Character code($input[[12-$i]])>=65) && (Character code($input[[12-$i]])<=70)) $msEpoch+=(Character code($input[[12-$i]])-55)*(16^$i) End case End for $msPerDay:=24*60*60*1000 $daysEpoch:=$msEpoch/$msPerDay $msRemainder:=Mod($msEpoch; $msPerDay) $result:=New object $result.msUnixEpoch:=$msEpoch $result.Date:=Add to date(!1969-12-31!; 0; 0; $daysEpoch) $result.TimeSeconds:=Time($msRemainder/1000) $result.Timestamp:=String($result.Date; ISO date; Time($result.TimeSeconds))+"."+String(Mod($msRemainder; 1000))+"Z" |
The method takes in a UUID in text format. It will then convert the Big Endian Unix Epoch time to a decimal value. This will then allow the date and time the UUID was created, in GMT time, to be calculated.
Below is an example that should return the current time in GMT when executed:
var $uuid : Text var $resObj : Object $uuid:=Generate UUID(7) $resObj:=Util_GetUUID7DateTime($uuid) |