We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38547
    • 98 Posts
    Hi using Rev0 2.2.8

    I presume I need to change a setting somewhere but when I use [[+publishedon]] in a chunk it just outputs a 0.

    Not sure if this is anything to do with it also but under system settings all the dates show as Jan 1 1970 including the ones that have gad settings changed like site name.

    Can anyone offer any clues

    Many thanks

    Ian [ed. note: ianman last edited this post 13 years, 2 months ago.]
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      Jan 1 1970 is the Unix epoch: it's 0 expressed as a date (according to Unix), so it's pretty common to see that as a date when dealing with code.

      Did you perhaps mean to use
      [[*publishedon]]
      instead?

      You may need to use strtotime or the date output filter (or both), and maybe test for nonzero values.
        • 38547
        • 98 Posts
        Thanks for the reply,

        I have now tried a number of things just within the site template such as [[*publishedon:strtotime:date=`%a, %d %b %Y %T`]] but this outputs nothing at all.
        As for using the [[+publishedon]] instead of the [[*publishedon]] was because I am using getpage and the date is meant to be output via a chunk so I was of the understanding that I needed the + otherwise it would output the date of the current document getpage is running inside of I might have that wrong but I have tried both.

        I found this post https://forums.modx.com/thread/?thread=56339.&i=1&page=3 copied that snippet called it outputdate then in my template added this [[outputdate]] not sure if I need to add something else to it but does not output anything as you can tell I am not a programmer.

        Is there any tutorial you might know of I can follow just to get any type of date format working this is just to show a posted on date.

        Thanks

        Ian
          • 24629
          • 370 Posts
          Is your resource published? when it isn't published [[*publishedon]] is supposed to be 0

          RDG
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Resource #1, which is installed by default, does not have a "publishedon" date, since it was never actually published.
              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
              • 38547
              • 98 Posts
              Everything is published but I also tried created on with same result.

              However I also found this post and used this fixdate snippet https://forums.modx.com/thread/44926/displaying-properly---converting-any-unix-timestamp-for-display

              To call this snippet I used
              [[!dateFix? createdon:strtotime:date=`%a, %d %b %Y %T`]]


              and the output of this is:
              &timeStamp patameter not set!

              Does that offer any clues I am totally lost!

              Many thanks for help so far

              Ian
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Here's a chunk tpl I just tried, using pdoResources (a mostly drop-in replacement for getResources)
                <li>[[+pagetitle]] - [[[[+publishedon:is=`0`:then=`+createdon`:else=`+publishedon`]]:date=`%a, %d %b %Y %T`]]</li>
                  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
                  • 38547
                  • 98 Posts
                  Quote from: sottwell at Aug 08, 2013, 04:24 AM
                  Here's a chunk tpl I just tried, using pdoResources (a mostly drop-in replacement for getResources)
                  <li>[[+pagetitle]] - [[[[+publishedon:is=`0`:then=`+createdon`:else=`+publishedon`]]:date=`%a, %d %b %Y %T`]]</li>

                  I just tried dropping that straight into the template with no output am I meant do to anything else with that.

                  Also I looked at the database using phpmyadmin and the pub_date column under the mod_site_content is just all 0
                  Could it be that no time is being recorded in the database.
                  I am using a cloudhost account with TSOhosts not sure if that might be an issue.

                  Many thanks

                  Ian
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Ok, if the database is all 0 then you have a problem with recording dates. Check your PHP default_timezone setting; also check your PHP error log to see if you're getting any errors for that.
                      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
                      • 38547
                      • 98 Posts
                      Quote from: sottwell at Aug 08, 2013, 04:37 AM
                      Ok, if the database is all 0 then you have a problem with recording dates. Check your PHP default_timezone setting; also check your PHP error log to see if you're getting any errors for that.

                      I might have to raise a support ticket with the hosts as I am only use to a cpanel backend and there is no php error log visible on this control panel.

                      Can I ask what I need to get checked o the php default timezone settings this is stuff I have never been involved with.

                      At least I know why none of my date setting would work.

                      Many thanks