.NET date string format for dotliquid epoch time

129 views Asked by At

I am currently working with .NET string formatted dates in dot liquid and want to convert my date to the current seconds since January 1 1970/epoch time. The problem is most of the references online are in ruby and feeling slightly stuck on where to go from here.

For formatting ruby strings we can do the following with dotliquid:

{% assign nowDate= "2022-11-20" %} {{nowDate | date :"%s"}}

Result: 1668902400

Now when it comes to .NET it's a little bit different. I haven't been able to find a way to convert my data value to epoch time.

I have tried a few different ways with no luck. I am trying to convert my original date to epoch to add days. For example this won't give me the right result :

{% assign nowDate= '2022-11-20' %} {{nowDate | date :'%s'}}

Result:0

I am aware of the .NET string format values : https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings

But I was wondering if anyone could point me to the right direction when working with .NET strings in dotliquid.

0

There are 0 answers