XF 1.4 Adding publishDate rich snippet to reviews - how to get ISO 8601 format in templates?

Stuart Wright

Well-known member
Licensed customer
Folks I am displaying the date of reviews using this template code:
Code:
<xen:datetime time="$content.publish_date" />
I want to add a rich snippet so that Google picks up the date of our reviews.
E.g. https://www.avforums.com/review/panasonic-tx-50cx802b-cx802-cx800-4k-review.11261
What template code would I use to display the above $content.publish_date in the ISO 8601 format, please, so I can add a publishDate rich snippet?
Thanks
 
Code:
{xen:date $content.publish_date, 'Y-m-d'}

There's a similar syntax - it's basically the same format as the XF date picker. Though the above I have used to demonstrate you can pretty much format a date in whatever format you like based on the standard PHP formatter options: http://php.net/manual/en/function.date.php

Alternatively you can just use:
Code:
{xen:date $content.publish_date, 'picker'}
 
Thanks again, Chris :)
The date validates ok using 'Y-m-d', so that will do nicely.
Just out of interest, using 'c' as the date format (which is officially the ISO 8601 format) is not handled by Xenforo and returns 'c' as the actual date value. This is what confused me originally.
 
Back
Top Bottom