Forum Discussion
How to convert a string value in JSON payload and using the date filter
Hi fellow Bonfirers,
Hope you are all doing well and kicking goals π Need some help to convert a string value that is passed in JSON payload " 2023-05-29T00:00:00.000+00:00 " to date for use in SMS. The below liquid {{event_properties.${due_date} | date: '%e -%b -%Y'}} still outputs the UTC string value 2023-05-29T00:00:00.000+00:00
Cheers | Raj
Hi Rajorigin
I hope you are kicking goals also! π₯
Is this what you are looking for:
2023-05-29
If so try this:{% assign utcTimestamp = "2023-05-29T00:00:00.000+00:00" %} {% assign localTimestamp = utcTimestamp | date: "%Y-%m-%d" %} {{ localTimestamp }}
It assigns the current value to a variable which allows you to edit it. The second assign variable takes the value you assigned to 'utcTimestamp' and essentially strips off the 'time' portion of the UTC with liquid. You can edit this however you like to get the date to show the way you want.
Finally, the end result is rendered with liquid.
I don't have a similar value to test it with but you can possibly assign your due date custom event property directly to the first assign function. If that doesn't work, assign the custom event property to it's own assign variable and feed it into the above liquid. Basically, assign, on assign, on assign... infinite assign π
Feel free to reach back out if you needed something more. Happy to keep looking at it.
π
- DavidOStrategist II
Hi Rajorigin
I hope you are kicking goals also! π₯
Is this what you are looking for:
2023-05-29
If so try this:{% assign utcTimestamp = "2023-05-29T00:00:00.000+00:00" %} {% assign localTimestamp = utcTimestamp | date: "%Y-%m-%d" %} {{ localTimestamp }}
It assigns the current value to a variable which allows you to edit it. The second assign variable takes the value you assigned to 'utcTimestamp' and essentially strips off the 'time' portion of the UTC with liquid. You can edit this however you like to get the date to show the way you want.
Finally, the end result is rendered with liquid.
I don't have a similar value to test it with but you can possibly assign your due date custom event property directly to the first assign function. If that doesn't work, assign the custom event property to it's own assign variable and feed it into the above liquid. Basically, assign, on assign, on assign... infinite assign π
Feel free to reach back out if you needed something more. Happy to keep looking at it.
π