We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26914
    • 8 Posts
    I just started my first ModX project tonight and am wanting to output each page’s publish date in a very specific format. Currently the only way I can find to output the date is using [*createdon*] but that outputs UNIX time, and I have no clue how to format it from there or whether or not I can use the same TV multiple times to do what I want to do.

    My desired end result for outputting the date posted would look like this:
    <p class="date">Jan <b>28</b> <small>2009</small></p>


    I’m assuming (hoping) there’s a simple TV to grab a portion of the posted date, but don’t know where to start looking.
      • 26914
      • 8 Posts
      This seems like way too much PHP and custom code for something as simple as getting the posted date output. Why isn’t there a cleaner method of doing this? Literally every other CMS I’ve used gives you a date output function.
        • 16278
        • 928 Posts
        If you install the PHx plugin, you can do many useful things to manipulate the output of document fields and placeholders, including formatting dates, e.g.
        Created on [*createdon:date=`%d %b %Y`*]

        (I had to search Extras for "placeholders" not "PHx" to return it in the repository - all part of the great MODx Treasure Hunt cool)
        http://modxcms.com/extras.html?view=package/view&repository=10&package=342
        KP
          • 26914
          • 8 Posts
          That’s much more like what I was looking for, but I’m not sure what I’m supposed to use for formatting characters. I’m used to PHP date() characters, and that’s obviously not what’s used here since %M gave me minutes instead of a 3 letter concatenation of the month name. Is this the same set of characters as Ruby?
            • 16278
            • 928 Posts
            Date formats as per PHP strftime() function - http://www.w3schools.com/PHP/func_date_strftime.asp. Less intuitive than date(), but it avoids having to set time locales to prevent error messages. wink
            KP