We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10076
    • 1,024 Posts
    Date error,

    hi I am using this Metatags extra on most of my site s. One small problem however. The copyright script bit, pulls the year 2005(?)

    // *** AUTHOR, COPYRIGHT, PUBLISHER and COMPANY ***
    $authorid = $modx->documentObject['createdby'];
    $createdon = date(Y,$modx->documentObject['createdon']);
    
      $MetaCopyright = " <meta name=\"copyright\" content=\"Copyright (c) $createdon by $authorname. All rights reserved.\" />\n";
    


    Changing that to following, the date jumps back to 1970 (?)

    // *** AUTHOR, COPYRIGHT, PUBLISHER and COMPANY ***
    $authorid = $modx->documentObject['createdby'];
    
    $createdon = date(Y,$modx->documentObject['createdon:date=`%d.%m.%Y`']);
      $MetaCopyright = " <meta name=\"copyright\" content=\"Copyright (c) $createdon by $authorname. All rights reserved.\" />\n";
    


    For the rest it s a nice snippet I think, so if someone could figure out what s wrong here)

    thanks.
    • The PHP date() function expects a UNIX timestamp. If you feed it a string, as you are doing when you pre-convert the field value, it will revert to 0, which was arbitrarily set as 1970 as the beginning of the "UNIX era". Since PHP uses the C libraries available on the server, some systems don’t support negative values (dates before 1970).
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 10076
        • 1,024 Posts
        Okay, understood, is there another way to fill that copyright bit with the website "create on date?". I just could leave it out or "hardcode" it, I guess?

        Solved it the hardcoding:

        // *** AUTHOR, COPYRIGHT, PUBLISHER and COMPANY ***
        $authorid = $modx->documentObject['createdby'];
        $createdon =2011;
        • Did you take a look at how it was done in MetaX by any chance?
            Patrick | Server Wrangler
            About Me: Website | TweetsMODX Hosting