How to Create a Unix Date / Time Stamp?

I'm trying to create a unique identifier and unix time seems like a good option but didn't see how to create a unix date stamp in the documentation (
Dates and Times [Keyboard Maestro Wiki]). Is this possible?

I did see something close but don't recognize the "A" in the format string -- what is "A" outputting?

In a Calc field:

NOW()

Unix time will provide a unique ID, but it does not reveal any other info.

That's why this was offered in the Wiki:

Usage Token and Format Results
Use in File Name %ICUDateTime%yyyy-MM-dd-HHmmssA% 2015-11-28-15210755267426

As mentioned in the wiki article, you can see all of the iCU D/T codes here:
For the complete list of codes, see the ICU Date/Time codes.

How unique to do you need it to be?

Will it only be created/used on a single machine by a single user/macro?

Is it possible that more than one instance of the macro/script you use to generate it could be running simultaneously, perhaps even within the same millisecond (the '%A' time format string provides milliseconds)?

If it just needs to be "good enough" then this may not be a problem. But if you need this to scale in any way, try Googling for "generate a strong unique id"...

Best wishes,
Steve

Thank you all. Setting variable to calc is perfect and I've also bookmarked those ICU Date/Time codes for reference.

Steve, you raise a good point about uniqueness. For now, milliseconds should be sufficient but if my process scales and is run programmatically, I'll explore a more robust unique identifier.

1 Like