Understanding the format of the Get Date Modified to Variable

I wish to select a set of files of files and then extract and write to a variable (and then later be added to a database) the filename and modification date of all the selected files.

For the modification date a date such as 25 December 2022 is turned into "1664704407".

Is there a way to turn this number into a 'proper date' (such as 25 December 2022)?

Any help gratefully received

Keyboard Maestro Actions.kmactions (2.6 KB)

If the date format is always DAY MONTHNAME YEAR, then you can break it apart with something like this:

image

Regex is:

(\d+) (January|February|March|April|May|June|July|August|September|October|November|December) (\d{4})

Then convert the month name to a number as described in the answers to:

Peter,

Thank you for the response. I am sure it is my lack of knowledge but I do not see to be able to relate your response to my question.

In the Finder selection I have the following folders/files selected:

and when I run my Keyboard Maestro macro, for the folder entry:

Hookmark Files 25 Dec 2022 at 10:52

I get:

Hookmark Files, 1671965539

The number represents the modification date set to the variable: %Variable%vFileModificationDate%.

It is this large integer which I wish to turn back into a readable date.

Help with this would be greatly appreciated.

The long numeric unix date strings represent a number of seconds since the new year fireworks at the Greenwich meridian on Jan 1 1970

To convert them to a human legible format of some kind you can use Keyboard Maestro's %ICUDateTimeFor% token.

For example:


See:

1 Like

ComplexPoint

Thank you very much for the answer - problem solved.

1 Like

problem solved

Good.

As I think you've probably discovered, you can, of course, replace the numeric string with a KM variable name.

Formatted date from ICUDateTime numeric string.kmmacros (2.5 KB)

2 Likes

ComplexPoint,

Thank you for the further help. Help in getting the right way to use a variable.

Thank you again.

1 Like