We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46886
    • 1,154 Posts
    Wow, I got lucky again. Date Registered doesn't show up in the profile.

    The correct code is [[*createdon:strftime=`%A %B %d, %Y'`]] rather than [[+createdon:strtotime:date=%b %d, %Y]]

    The template is core/components/discuss/themes/default/pages/user/index.tpl
      • 46886
      • 1,154 Posts
      Dammit, I was wrong about this. It isn't working right, for some reason it provides a date of May 22nd rather than June 20th...it may be a calculation problem, I don't know, but it probably is a bug as every account i made today, over 8+ hours, has the precisely same createdon value of May 22nd, 2014, 01:57:00...
        • 3749
        • 24,544 Posts
        Try this (strftime wants a timestamp):

        [[*createdon:strtotime:strftime=`%A %B %d, %Y'`]]
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 46886
          • 1,154 Posts
          Oh hi BobRay, I didn't expect to see you over here smiley

          Yeah, that's the code from your site. But it leaves the data as a number, a fixed number 1400738220 for all users.

          I ended up with my "solution" starting from your code, because that turned it into a readable format, but failed to notice it was the wrong date.

          I will make another bug report on github. But I don't know whether to put it in Login or Discuss or what section.
            • 3749
            • 24,544 Posts
            You're right. It's because there's no strftime modifier unless you create one. I could swear that there used to be one, but I can't find it in the code history at GitHub, so I must have dreamed it. Stranger still, the date: modifier calls strftime() rather than date() -- which I think is a bad choice of names because it's confusing and date() uses different format tokens than strftime(). You can create a strftime snippet with the code below, but you might as well do this, since date: will call strftime():

            [[*createdon:strtotime:date=`%A %B %d, %Y`]]


            /* strftime snippet */
            if ( true === isset($options) ) {
                $format = $options;
            } else {
                $format = "%A, %d %B %Y %H:%M:%S";
            }
            return strftime($format, $input);


            BTW, if the date/timestamp is wrong, it's the fault of whatever writes it. Normally, MODX writes the current time() into that field when the resource is first created and then never changes it. Could you be confusing the editedon, createdon, and publishedon fields? [ed. note: BobRay last edited this post 9 years, 10 months ago.]
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 46886
              • 1,154 Posts
              I am just cutting and pasting what you give me BobRay, no changes of createdon or anything...

              Could this not be getting the *user* createdon data at all, possibly? I find that createdon field doesn't appear in the user info...its so strange to be a fixed number for all.
                • 3749
                • 24,544 Posts
                FYI, I've updated the blog post.

                The 'createdon' field is a resource field. It's set to the date that the Resource was created. It doesn't have anything to do with users at all.

                If you're looking for the date a user was created, I'm afraid there isn't one unless you create it yourself. You can make it an extended field or co-opt a user or profile field that you're not using (e.g., mobilephone, country, or fax).

                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 46886
                  • 1,154 Posts
                  [[*createdon:strtotime:date=`%A %B %d, %Y`]] leads to the same result of Thursday May 22, 2014...

                  This value *should* be created by register function of Login. Either login is saving it improperly or...

                  Or I don't know. This is getting a little deep for me.

                  Here is the structure of this template, just for context. I don't think it has any relevance or effect on this issue:

                      <ul class="profile">
                          <li class="f1-f5">
                              <div class="f1-f2">[[%discuss.name? &namespace=`discuss` &topic=`user`]]:</div> User
                              <div class="f3-f5"><strong>[[+name_first]] [[+name_last]]</strong></div> User Name
                           </li>
                          <li class="f1-f5">
                              <div class="f1-f2">[[%discuss.posts]]:</div>Posts
                              <div class="f3-f5"><strong>[[+posts]]</strong></div>User Posts
                          </li>
                          <li class="f1-f5">
                              <div class="f1-f2">[[%discuss.date_registered]]: </div>Date Registered:
                              <div class="f3-f5"><strong>[[*createdon:strtotime:date=`%A %B %d, %Y`]]</strong></div>
                  ...
                  </ul>
                    • 46886
                    • 1,154 Posts
                    Haha really! Wow that's great, a solution! The data doesn't exist is a valid reason why we can't get it haha! Thanks for the help!

                    Will take note of your point about co-opting some user/profile fields...no need to complicate things.
                      • 3749
                      • 24,544 Posts
                      Using an existing field rather than creating an extended field is significantly faster, especially if you're going to use that field for searches. It also saves you from having to create the extended field for every user.

                      Just be careful of the field types and their sizes (e.g., don't put it in a boolean field wink ). The 'dob' field is a good choice since it's a date field, if it's available. You can change the caption for the field in Lexicon Management (if you can find it wink ). Your change will survive upgrades.

                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting