#Current time in notifications

1 messages · Page 1 of 1 (latest)

ashen jacinth
#

I'm trying to add the current time into some discord notifications but cant seem to get it to work - the automations themselves are fine and outputting the rest of the text and images, but just not the timestamp part, am I messing up the format or missing something here:

action: notify.discord
data:
  target: "xxxChannelIDxxx"
  message: >-
    {{ now().strftime("%l:%M %p") }} {{trigger.payload_json["after"]["label"]}}
    at {{trigger.payload_json["after"]["camera"]}}

I tried both '%l:%M %p' and "%l:%M %p" but still no output.
Thanks in advance 🙂

#

(do I need to install an integration to expose this in my automations? or use a template somehow?)

vale knot
#

%l is not a strftime code. What did you want there?

ashen jacinth
#

the current 12-hour without the leading zero

vale knot
#

I guess that is %-I ?

#

{{ now().strftime("%-I:%M %p") }}
3:44 PM

ashen jacinth
#

not sure why those 2 websites dont match

vale knot
#

The %l specifier is supported in many Unix-like environments, Ruby, and PHP, but it is not universally supported in all implementations (such as Python’s standard library)

#

I guess your site is using a different language (even though it incorrectly claims python)

ashen jacinth
#

odd, let me try that, thanks