1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Styling and Customization Questions' started by Stuart Wright, Jun 9, 2015.

  1. Stuart Wright

    Stuart Wright Well-Known Member

    Folks I am displaying the date of reviews using this template 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?
  2. Chris D

    Chris D XenForo Developer Staff Member

    {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:
    {xen:date $content.publish_date, 'picker'}
  3. Stuart Wright

    Stuart Wright Well-Known Member

    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.

Share This Page