Formatting time a Draft was created

Hello, I am modifying this action Monthly Journal. I would like for the result be the following when I run it on a draft. The time is the time the draft was created, not the current time.

– 9:58pm: Some text

This code will show the current time:

let contentTemplate = `--[[time| %I:%M %p]]: [[draft]]
`

I tried this and it shows a long date / time:
let contentTemplate = -- + draft.createdAt + ': ’ + [[draft]]

So I want to format createdAt to just show 12 hour time format.
Also, instead of the text of the draft being saved, it shows “[object ActionKit.ScriptObjectDraft]”

Thanks for any help!

This should work:


draft.processTemplate("[[created|%I:%M %p]]")

The formats and how to access the created date in the template is Documented here

1 Like

Re your second issue - I didn’t try the action but first I wanted to check if you made any changes to it?

Thanks, the time formatting works great!

I don’t think I changed anything else, but I will compare the Monthly Journal in the action directory vs my code.

I copied the code from the action directory, then modified with the processTemplate you posted earlier and now everything is working as it should. Thanks so much for your help!

2 Likes

Great to hear! Happy journaling :slight_smile:

1 Like