Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get today's date in Jekyll with Liquid markup

This (should) be easy, I think, but I'm unable to get today's date to show in a Jekyll page using Liquid markup. According to the documentation, I should be able to do this to get this date's year:

{{ 'now' | date: "%Y" }} 

But all that gets rendered is the string now, not any formatted date. What am I doing wrong?

like image 295
Jeff Pratt Avatar asked Sep 17 '12 17:09

Jeff Pratt


2 Answers

It didn't work for me either. It appears you've hit a current bug in the Ruby 1.9.3 support. There is a pull request that fixes the bug, but it's not incorporated yet. A workaround is listed, perhaps it will work for you:

{{ site.time | date: '%y' }} 
like image 52
Mark Thomas Avatar answered Oct 18 '22 07:10

Mark Thomas


To get the whole year, for example "2015", from the site.time, you can either use:

{{ site.time | date: '%Y' }} # OR 20{{ site.time | date: '%y' }} 

To just get the last 2 digits from the year 2015, this will just output "15":

{{ site.time | date: '%y' }} 
like image 33
5ervant - techintel.github.io Avatar answered Oct 18 '22 07:10

5ervant - techintel.github.io