Salesforce

How Do I Retrieve the Current Time Using Milliseconds Precision? (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

How Do I Retrieve the Current Time Using Milliseconds Precision? (Magic xpa 4.x)

The Time() function returns the number of seconds since midnight. It is stored, internally, as the number of seconds, though it is usually displayed in an HH:MM:SS format.


Sometimes though, you might want more precision, generally for creating a timestamp. The mTime() function does this. It returns the number of milliseconds since midnight.

There is no automated function to display the number of milliseconds. If you want to fetch just the milliseconds, you can use the expression:

mTime() - Time() * 1000


Note: You might notice a similar function, UTCmTime(). The UTCmTime() function works the same as the mTime() function, but returns the current time value in milliseconds from midnight to the current UTC time.

Creating a timestamp using mTime()

You can create a numeric date/time stamp by using the expression shown here. This creates an 18-digit numeric code in the format:

YYYYMMDDHHMMSSmmm


Alternatively, you can create the timestamp as an Alpha string, but the Numeric version stores in fewer bytes.

See also

The Online and Rich Client Samples projects (program DT03 and RDT03)

Reference
Attachment 
Attachment