Jump to content

Formatting date time in slack integration


Recommended Posts

Hello,

We have a business process which posts to a slack channel using ibrige automation, the message posted is below:
Logged Development Release - &[global["inputParams"]["requestId"]] - &[global["flowcoderefs"]["getReqInformation"]["summary"]] at  &[global["flowcoderefs"]["getReqInformation"]["scheduledStartDate"]]

So this takes the variables "scheduledStartDate" and posts to slack, but this is showing as UTC :
Logged Development Release - RM00114913 - end to end - test 1 at 2022-05-24 08:00:00Z
 

Converted date time:
image.png.7341e9f3c3a3a5261d0b1ff30a59cabc.png


I understand the DB stores date times as UTC and scheduledStartDate will be outputting the raw value rather than converting to the regional time zone set.
The documentation for wiki markup did not resolve this issue.

How can i format the date time to local time zone in a slack message?

Link to comment
Share on other sites

9 minutes ago, Michael Risby said:

How can i format the date time to local time zone in a slack message?

@Michael Risby isn't this actually a question for Slack? It would make sense for Slack to also store dates in UTC and have the date formatted in the UI based on user or machine regional setting. With this in mind it also makes sense for the date to arrive in Slack in UTC and then have Slack format it in the UI... no idea how Slack does and where when it comes to dates.

Link to comment
Share on other sites

Slack can do when provided with a unix timestamp (which from digging im not sure hornbill can provide) 
so i was hoping there would be a variable that outputs converted to local time zone, like email templates do

Mike

Link to comment
Share on other sites

@Michael Risby the email template does format the date but, as you said is an output. Still won't recommend sending a date value formatted to a time zone in a different system. The risk is that the other system will take that vale and consider it as UTC...

We don't have any dedicated utility to get the Unix timestamp. But given that the Unix timestamp is basically the number of seconds since Jan 1970, the below "date difference" utility could be used to get that number. The difference is (also) outputted in seconds and that would be what you are after...

image.png

Link to comment
Share on other sites

sounds like a cool solution, having a bit of trouble getting it working though
image.png.684c658a9d842b8f7a21d35077c850b9.png

Feel like it may be exceeding some field sizes, outputs from the date difference to 1970:

 &[global["UtilitiesGetDateDifference"]["days"]] - 19136
&[global["UtilitiesGetDateDifference"]["hours"]] - 9

&[global["UtilitiesGetDateDifference"]["minutes"]] - 0
&[global["UtilitiesGetDateDifference"]["seconds"]] - 0

Or am i just using it wrong?

Link to comment
Share on other sites

Posted (edited)

@Michael Risby ermm... right, no, not using it wrong. I misread how the values are outputted :( ... it will return "days AND hours AND minutes AND seconds" as opposed to "days OR hours OR minutes OR seconds" ...

I'll ask devs if they can add an output for the UNIX timestamp on this node:

image.png

 

Meanwhile you can use the same node to format the date in reginal timezone. Not recommended as a solution given the maintenance overhead with shifting timezones (e.g. BST)

Edited by Victor
Workaround no longer needed as a permanent solution was deployed
Link to comment
Share on other sites

This worked a treat, for anyone searching for this, slack message in hornbill would look like:

<!date^&[global["UtilitiesGetTimestamp"]["timestampUnixS"]]^{date} at {time}|&[global["flowcoderefs"]["getReqInformation"]["scheduledStartDate"]]>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...