Forums/Bugs & Fixes

Wrong Year when using dates...

Luke
posted this on May 23, 2011, 12:25

I'm using  <w:date format="%Y">  and keep getting 2010 as output... i'm sure it's 2011! ;)

 

Comments

User photo
Christopher Haupt
Webvanta

The date tag's behavior is somewhat dependent on the context in which it is being called. Per your example, it will either return the published_at date of the current page OR the date of a database item.

If you just want to get the CURRENT date based on the calendar, add the "for" attribute with the value of "now":

<w:date format="%Y" for="now" />

If using the "now" value, remember if the page is cached, it might show the wrong time/date until the next time the page is re-rendered. This is probably not an issue for the "year", though!

May 23, 2011, 15:38