How do I force English time.Format?

Since v0.87.0, time.Format returns localized strings, which is all nice and well in human-facing text, but breaks all machine-readable things on non-English sites. For example, RSS 2.0 requires date to be in RFC 822 format, and that requires English day and month.

How do I force time.Format to behave?

1 Like

Good question … You currently need to use .Date.Format;

1 Like

But that only works with builtin dates, doesn’t it?

To have a date read from a JSON resource be properly formatted by Hugo I need to stick to v0.86.1, right?

Try something like this

{{ $date := time <read date from your JSON file> }}
{{ $date.Format "2006-01-02T15:04:05-07:00" }}

See time | Hugo

4 Likes

Clever! This actually works, thanks a lot!

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