We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32753
    • 2 Posts
    In the current template I use the top of each page shows the current date & time using snippet DateTime. Instead of the actual date & time, I would like to show the published date/time or the edited date / time. So I created a new snippet called UpDateTime that has the following code (and of course, this snippet is called instead of the DateTime snippet in the Default Template code):

    if($pub_date > 0 ) {
    $timestamp = $pub_date ;
    } else {
    $timestamp = $editedon ;
    }

    return strftime("%d-%m-%Y %H:%M:%S", $timestamp);

    Unfortunately, this always returns "0" (or actually: Jan 1st 1970, 00:00 )

    Q: how can I do this the right way?
      • 23703
      • 180 Posts
      You are not using the right variables. Use this form
      $timestamp = $modx->documentObject['editedon'];


      And you could look here for more inspiration.
        • 6726
        • 7,075 Posts
        You could also check out the PHx Plugin

        PHx (Placeholders Xtended) will add the capability of output modifiers when using placeholders, template variables and settings tags. It also supports nested tags.
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l'outil id
          • 32753
          • 2 Posts
          thnx a million!
          that really helped
          (and I understand the modx variables a lot better now!)