Hi!
I’m trying to get the __from and __to variables in a particular format: YYYY-MM-DD-HHmmss. I also need them to be in UTC timezone. I seem to be able to get either one or the other, but not both.
I can get the format I want like this, but it is converted to my browser/local time (UTC+8:00):
${__to:date:YYYY-MM-DD-HHmmss}
and I can get it in UTC with this, but then the formatting is different:
${__to:date:iso:YYYY-MM-DD-HHmmss}
As shown in this screenshot:
I could write some javascript to get the exact string I want, but is there a way I can do it with just the variables?
Thanks!
I have the same issue. ${__to:date:iso:YYYY-MM-DD-HHmmss} with iso format does not even work for me
1 Like
This is because, as per their Global Variables documentation, you can not use colons in the custom date format (which is ridiculous because nearly every single timestamp format on the planet uses colons in at least 1 place of the datetime string…). However, there is a workaround I saw recently where you use several custom date variables and manually placing colons in between them as needed.
Like this (obviously you would modify the formatting and use-case based on your own needs):
https://<<YOUR_API_URL_HERE>>/<<YOUR_API_PARAMETERS_HERE>>&start_date=${__from:date:YYYY-MM-DD HH}:${__from:date:mm}:${__from:date:ss}&end_date=${__to:date:YYYY-MM-DD HH}:${__to:date:mm}:${__to:date:ss}
I have found that instead of stringing together multiple instances of __from:date
or __to:date
, you can simply escape the colons. I have this working as HTML in a Text panel:
<div style="font-size: 16px;">
Time Range: ${__from:date:YYYY-MM-DD HH\:mm\:ss} to ${__to:date:YYYY-MM-DD HH\:mm\:ss} UTC
</div>
2 Likes
You’re a legend @thomasnabelek ! I could have swore we tried that and some point in the past, but I guess not. Great work and thanks for sharing!
1 Like
Just noting that the solutions given here don’t print the date in UTC, only local time. I am still looking for a way to have it printed in the chosen format in UTC.