Retrieving timestamp and specify it in ISO format

Hello 😊

Here's my Assign Message Policy, I'm trying to get the value of the timestamp by following the ISO format, however using this configuration, I am unable to do that.

    <AssignVariable>
        <Name>timeStamp</Name>
        <Template>{timeFormat('yyyy-MM-dd\'T\'HH:mm:ss.SSSXXX',system.time)}</Template>
    </AssignVariable>

Any help is greatly appreciated, and thank you in advance!

Solved Solved
1 3 449
1 ACCEPTED SOLUTION

Try this

 

<AssignMessage name='AM-Timestamp'>
  <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
  <AssignVariable>
    <Name>iso8601Format</Name>
    <Value>yyyy-MM-dd'T'HH:mm:ss'Z'</Value>
  </AssignVariable>
  <AssignVariable>
    <Name>formattedTime</Name>
    <Template>{timeFormatUTCMs(iso8601Format,system.timestamp)}</Template>
    <!-- expresed in UTC, eg, 2020-10-02T15:59:26Z -->
  </AssignVariable>
</AssignMessage>

I guess I should put that into the documentation as an example, eh?

 

View solution in original post

3 REPLIES 3

Try this

 

<AssignMessage name='AM-Timestamp'>
  <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
  <AssignVariable>
    <Name>iso8601Format</Name>
    <Value>yyyy-MM-dd'T'HH:mm:ss'Z'</Value>
  </AssignVariable>
  <AssignVariable>
    <Name>formattedTime</Name>
    <Template>{timeFormatUTCMs(iso8601Format,system.timestamp)}</Template>
    <!-- expresed in UTC, eg, 2020-10-02T15:59:26Z -->
  </AssignVariable>
</AssignMessage>

I guess I should put that into the documentation as an example, eh?

 

This is awesome, thanks @dchiesa1!

I was about to use a js to do that, but didn't know assign message was this powerful. 

CharK_0-1698369827237.png

anyway, here's the screenshot from the trace.

Nice, it works!