Search code examples
htmldatehandlebars.jsghost-blog

How can I modify my Ghost.org blog's date format


My Ghost.org blog displays dates as:

04 Nov 2013

This is controlled in content\themes\{theme-name}\post.hbs via:

<time datetime="{{date format="YYYY-MM-DD"}}">
    {{date format='DD MMM YYYY'}}
</time> 

I want this changed to a different format, like Wednesday, 4th November 2013, how can I do this?


Solution

  • Ghost uses Moment.js to output dates.

    From their display format documentation we can determine that:

    • dddd can be used to output the full day name;
    • MMMM can be used to output the full month name;
    • Do can be used to output the date in 1st 2nd 3rd 4th... format;
    • YYYY can be used to output the full year number.

    From this we can craft our desired date format in content\themes\{theme-name}\post.hbs using:

    <time datetime="{{date format="YYYY-MM-DD"}}">
        {{date format='dddd, MMMM Do YYYY'}}
    </time>
    

    Wednesday, 4th November 2013