Hi there,
Today I’m going to write how to change date and time format of posts on Jekyll.

Date and time of a post

To display a post published date, we can use a variable {{ page.date }}.

The date and time look like this:
2022-05-15 00:00:00 +0900

{{ page.date }} can be manually set in a post front matter in the following format: ---
date: 2022-05-15 09:30:00 +0900
---

Published time and time offset can be omitted. In that case, they are displayed like 00:00:00 +0900, time offset is according to your timezone.

Using liquid filters

Here are some liquid filters available to format date and time.

{{ page.date | date_to_string }} converts post date to short format
like this:
15 Apr 2022

{{ page.date | date_to_long_string }} converts post date to long format
like this:
15 April 2022

Formatting published date

There are several ways to format post date.

For example,
{{ page.date | date: “%a %b %d, %y” }}
will display
Fri Apr 15, 22

When we use uppercase %A, %B and %Y as filters,
it diplays the date like this:
Friday April 15, 2022

%m displays month in 2 digits number.
For example, this filters display month and day
{{ page.date | date: “%m-%d” }}
and it will be like this:
04-15

Formatting published time

To display post’s published time, we can use this.
{{ page.date | date: “%H:%M” }}
It will be like this:
09:30

Other ways to format time are using %r and %R.
Each will looks like this:
01:25:00 PM and 13:25

In Closing

Now we know there are many filters available to format blog post published date and time. We are always able to do some experiments to find out which way will suit our blog theme.

That’s all for today.

See you