Azure Logic App | Liquid

Abhay Chandramouli 991 Reputation points
2023-05-02T14:40:17.89+00:00

I want to convert a given utcNow() time stamp in logic apps liquid transformation to unix timestamp like 1666861645116.

Please help me do this with liquid example code

Thanks in advance

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,996 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 27,111 Reputation points Microsoft Employee
    2023-05-03T04:23:42.9266667+00:00

    Since the ticks() function isn't available in Liquid, you can try using date filter to convert; {{ 'now' | date: '%s%N' }}. If that doesn't work, you could try doing your own function

    # Convert a UTC timestamp to ticks
    # Usage: {{ '2022-01-01T00:00:00Z' | to_ticks }}
    #
    # Note: This filter assumes that the input timestamp is in UTC format.
    
    module ToTicksFilter
      def to_ticks(input)
        Time.parse(input).to_i * 10_000_000 + 62_135_596_800_000_000
      end
    end
    
    Liquid::Template.register_filter(ToTicksFilter)
    

    where the usage would be {{ '2022-01-01T00:00:00Z' | to_ticks }}.

    1 person found this answer helpful.
    0 comments No comments