Learning How to Use KM Variables with Various Date/Time Formats

I have struggled with this and I can't see what I am doing wrong, I try not to keep asking questions until I have put a lot of effort into it but this one is escaping me I am afraid.

I partly post so that some of you can see the problems a beginner might get. I am sure the answer is blindingly obvious to some of you. The Variable is in my Variables in preferences with the string of numbers shown in the right hand panel. I assume the string of numbers is a system way of recording time? But it won't render in a readable date. I tried it on another file initially and at least I understand what that arrow at the bottom of the box means now.

This is for learing how to use variables. For when I really need it you might say.

Keyboard Maestro 8.2.4 “test macro for learning variables” Macro

This is NOT a "Variables" issue.

Yes, it is the Unix time for the file Creation Date.

If you want it in human readable form, then you need to use the ICUDateTimeFor token. Something like this:
%ICUDateTimeFor%<DateInUnixTime>%<format>% - the specified unix time date.

So for your use case:
%ICUDateTimeFor%Bethel%yyyy-MM-dd%

image

Note that since the <DateInUnixTime> is in a "Calculation" field, you do NOT use the Variable token with "%" -- you just enter the plain Variable Name.

For the ICU format codes, and more info, see Dates and Times .

Does that help?

1 Like

@tudor_eynon, I hope you don't mind that I have revised your topic title to better reflect the question you have asked.

FROM:
Keyboard Maestro 8.2.4 “test macro for learning variables” Macro: what is wrong with this?

TO:
Learning How to Use KM Variables with Various Date/Time Formats

This will greatly help you attract more experienced users to help solve your problem, and will help future readers find your question, and the solution.

1 Like

@JMichaelTX thanks. As always the revision improves and clarifies.

You may call me Tudor by the way as may anybody else here. You may also take it as read that you may alter, delete, add to etc. etc. any post of mine on this forum. I give you full licence and other moderators too. That includes alterations, additions to any macros I post too. I am still working on some.

1 Like

Yes it does. I guessed that one had, in some way, to 'translate' as it were using that ICUTime process or whatever it is that it stands for. I would have taken a long time to get to the expression you used, written that way though, if ever. Thanks again for your time.

Slightly off topic.

Have any of you, you in particular, ever though of doing a kind of screencast series just for Variables? On the lines of David Sparks Field Guides? I would cetainly shell out. I am now locked in to Keyboard Maestro to be honest. I have had it a few years but I would say that only in the last three months if it is off for any reason I feel my computer isn't working right. More so now than Launchbar.

1 Like

You need to take more advantage of the Official Keyboard Maestro Wiki . A search there on date/time will provide most of the info you needed for this case.

Also, you can easily access the ICU tokens from the Set Variable text field:

1 Like

I did look there and I didn't undertand it somehow though; that 'For' didn't have any significance and I missed it: I can see now what it means though. I ticked your first reply, I understood it straight away.

I use the Date Time formats a lot, I just didn't know you could write them up against that other variable as it were. Thanks though, I usually only post by the way when I have totally failed after a) looking here b) the Wiki c) Sparky's Field Guide and d) taking some time to think about it. Sometimes it just doesn't click. I see now though how it 'works'.

1 Like