Skip to main content

Liquid: Get current year

I'm trying to use Liquid to include the current year in my site footer. According to the official documentation, this should do the trick:

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

However, this just outputs the word 'now'.

Does anyone know how to get the current year using Liquid?

Official response from

Hey Jerad,

I think you're referring to documentation from Shopify. For NationBuilder, our date and time availabilities can be found here.  

Currently, date and time are variables associated with events. They would look like this:

{{ event.event.local_start_at | date: '%A, %B %d, %Y at %I:%M %p' }}

Another interesting variable is the one that can display when the last time the site stats where updated:

{{ settings.stats_updated_at }}

It is easy to add in a time and date js code though to do the same thing. You can find many examples on the net that do this. Here is one example that you could modify for your purposes that outputs the date in the format Tuesday, July 16, 2013:

<script language="JavaScript">
var now = new Date();

var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');

var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;
}
today = days[now.getDay()] + ", " +
months[now.getMonth()] + " " +
date + ", " +
(fourdigits(now.getYear())) ;

document.write(today);
</script>

Share this post

Showing 8 reactions

How would you tag this suggestion?
Please check your e-mail for a link to activate your account.