cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
898
Views
20
Helpful
2
Replies

Getting epoch time in Webex Flow Designer using Pebble

donnytheguy
Level 1
Level 1

Hello,

I'm trying to use the Cisco Developer API but in order to do so I want the current epoch time and the epoch time 24 hours ago - to be used in the to and from in my GraphQL query. I was wondering if it was possible to do this in the set variable block using Pebble syntax. Or even possible to do directly in the Curl request as Date.now() or something similar? Any advice would be great!

Thanks,

Donny Miller

1 Accepted Solution

Accepted Solutions

Hi Team,

This was fixed - this is the way of getting the epoch timestamp in flow.

{{ now() | epoch }}   => default UTC timezone and in seconds
{{ now() | epoch(inMillis=true) }} => default UTC timezone and in milliseconds
{{ '2017-10-19 16:18:03.779' | epoch(format='yyyy-MM-dd HH:mm:ss.SSS', inMillis=true) }} => custom format and in milliseconds
{{ '2017-10-19 16:18:03.779' | epoch(format='yyyy-MM-dd HH:mm:ss.SSS', inMillis=true, timeZone='America/Phoenix') }} => custom format with timezone and in milliseconds

Thanks & Regards,

Arunabh.

 

View solution in original post

2 Replies 2

Arunabh Bhattacharjee
Cisco Employee
Cisco Employee

Hi Donny,

This does not exist today, we've opened up an enhancement internally to get it added. The pebble engine uses the SimpleDateFormatter class but does not use a getTime() method to allow for Date --> Epoch

(ref: https://github.com/PebbleTemplates/pebble/blob/master/pebble/src/main/java/com/mitchellbosecke/pebble/extension/core/DateFilter.java)

So it is likely that we will introduce another method, just like {{ now() }} that exists purely in Flow Engine to allow for both, epoch.now() and epoch.from(< Date Time String> )

For now however, you can use an external API such as :

https://worldtimeapi.org/api/timezone/America/Chicago

to get the epoch timestamp and then * 1000 for millis 

Thanks & Regards,

Arunabh.

Hi Team,

This was fixed - this is the way of getting the epoch timestamp in flow.

{{ now() | epoch }}   => default UTC timezone and in seconds
{{ now() | epoch(inMillis=true) }} => default UTC timezone and in milliseconds
{{ '2017-10-19 16:18:03.779' | epoch(format='yyyy-MM-dd HH:mm:ss.SSS', inMillis=true) }} => custom format and in milliseconds
{{ '2017-10-19 16:18:03.779' | epoch(format='yyyy-MM-dd HH:mm:ss.SSS', inMillis=true, timeZone='America/Phoenix') }} => custom format with timezone and in milliseconds

Thanks & Regards,

Arunabh.