dateFormat - unable to parse "2021-03-24T09:38+11:00"

I have a string from my CMS of the date which is in the format “2021-03-24T09:38+11:00” - I need to parse this so that I can have a nice “24th March 2021” but dateFormat doesn’t seem to be able to cope with it. I stumbled across Hugo dateFormat and it doesn’t seem to be on the list. Any ideas on how I can parse it? Thanks

Maybe I can do a replace on “+11:00” and add a “:00Z” which will make it parse… Can you nest functions?

I think it won’t parse because the seconds are missing. Try something like this:

{{ replace $date "+" ":00+" | dateFormat "Monday, Jan 2, 2006" }}
1 Like

Thank you! spot on.

One other issue, this works on “list” pages, but “content” pages this doesn’t parse because of the $.Param and replace sees it as another arg

{{ replace $.Param "publishedOn" "+" ":00+" | dateFormat "Monday, Jan 2, 2006 at 15:04" }}

Any ideas what syntax to use instead of $.Param "publishedOn"?

I just fluked it, it works.

{{ replace ($.Param "publishedOn") "+" ":00+" | dateFormat "Monday, Jan 2, 2006 at 15:04" }}

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.