Wrong Liquid filter?

For some time now, I’ve found that my generated feeds all output dates which make it look like the items were published at 12 AM. This leads to items like notes being displayed out of order. Obviously this isn’t the case based on modification times of the files, but I’m wondering if there is a simpler way to fix it.

Looking at my feed template, I’m using {{ note.date | date: "%a, %d %b %Y %H:%M:%S %z" }} for a note’s pubDate - which is wrong - instead of - for example - {{ site.time | date: "%a, %d %b %Y %H:%M:%S %z" }}, which gives me a correct date for the entire feed. I can swap this out, but it raises a question…

Is there is a built-in filter that will output the same format or do I need to use a plugin?

You can make it reusable by by adding it as a custom configuration option.

In your _config.yml file, add the following new line:

myDateFormat: "%a, %d %b %Y %H:%M:%S %z"

Remember if you are serving Jekyll locally at the moment, quit and re-run Jekyll.

Next, wherever you want to use that new format, add the following code:

{{site.time | date: site.myDateFormat}}

The output will look like this:

Thu, 16 Feb 2023 18:53:52 +0000

Which is what I think you expect to see.

In the future, it would be great if you show examples of the date formats you received, including when you would expect as I had to run Jekyll to see the date output.

Hope this helps!

edit: took my own advice and added my code output :slight_smile: