Format bug in "createdon", "publishedon"!

Hello everybody!

First of all:
Please excuse my uggly english - I’m writing from Germany (Dresden).

  1. My nickname is not acceptable!
    I’m just arrived to this community - thank you, to let me in!
    But I wonder why the robot had problems with my nickname “ejomi”
    which is pretty unique - only “ejomi-1” works - why?
    However, now I’m here and - may be - can do a bit more in future.

  2. How about the german community?
    I’m working as webdesigner nearly 20 years but never heard of MODX before

  • how unlucky! Now I’m playing arround with it since a couple of weeks and
    be very impressed. I wonder why MODX is so uncommon in the german environment.
    MODX is incredible - I love it!!!
    It seems, that the german MODX-forum is dead and unfortunately I did’t find
    no german section within this new MODX-forum. Is there something planned?
  1. OK - let’s come to substance:
    During my playtime I found the system-tv’s “createdon”, “publishedon” and “editedon”.
    They can be formattet like [[*createdon:strtotime:date=%Y-%m-%d]] - fine!
    In addition to the post “pdoResources and publishedon Date Formatting” I can report, that unfortunately the “createdon” accepts “%Y-%m-%d” as formatstring
    which is NOT correct for the PHP date but PHP strftime functionality!!

The following should work with the system format string - but doesn’t:

This is why: The systemkey “manager_date_format” accepts the format string “Y-m-d”
which is absolutely PHP-conform but - as I said - not capable for “createdon”!

Those are my 3 paragraphs for the beginning. Hopefully hearing from you: a nice day to you all!


As far as the German Community goes, it is also present in this forum :wink:

I have never used the german forum though as this one is the main spot for all the highly knowledgeable people around this CMS, which I wouldn’t want to miss out on. Also it’s very likely that any problem has been discussed here before already. And all the docs and everything else are most likely available in english. The only barrier therefore is the language, which is a personal preference I guess…

Glad you found this forum, welcome! :slight_smile:

I think your trouble is caused by the fact that the unfortunately named MODX :date output modifier actually calls strftime() rather than date().

Here’s the code:

case 'date':
       /* See PHP's strftime - */
             if (empty($m_val)) {
                  $m_val = "%A, %d %B %Y %H:%M:%S"; /* @todo this should be modx default date/time format? Lexicon? */
             if (($value = filter_var($output, FILTER_VALIDATE_INT)) === false) {
                    $value = strtotime($output);
             $output = ($value !== false) ? strftime($m_val,$value) : '';

… thank you for your quick reply.
This means: The trick, using [[++manager_date_format]] will never work because the date string there is defined like “Y-m-d”.
OK - it’s not that tragic: so we have to insert the format string manualy ("%Y-%m-%d) but everybody should know about this problem. Anyhow: Considering multi language support I think this should be corrected some day to have the functionality of dynamic format changes using [[++manager_date_format]].
Have a nice day - greetings from Dresden (Saxonia, Germany):

The output filter will use a snippet if it doesn’t find a built-in modifier.

So you should be able to create a snippet called myDate with this code:

$format = $modx->getOption('manager_date_format');
return date($format, $input);

Then this should work:


If it’s for the current resource, I would be inclined to do it with a custom, two-line snippet called MyCreatedOn with this code. It would be much faster since MODX doesn’t have to parse the tag and call the various output modifiers. It also avoids the unnecessary call to strtotime().

/* Get timestamp */
$createdOn = $modx->resource->_fields['createdon'];

/* Format and return value */
return date($modx->getOption('manager_date_format'), $createdOn);

Then this would display the value: