We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    Trying to format a date, it isnot working:

    [[+startdate:date=`%A %B %e %Y`]] [[+starttime:strtotime]] - [[+venue]], [[+city]]


    It will always returns "Thursday January 1 1970" and an epoch formatted time... both columns in the database are date and time types, if I remove the formatting from the output, I get the correct date & time but wrong format...

    What is the problem here?

    [Revo 2.2.2 linux]
      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525
      • 9102 ☆ A M B ☆
      • 318 Posts
      Try converting to epoch time first, then using the date output modifier:

      [[+startdate:strtotime:date=`%A %B %e %Y`]] [[+starttime:strtotime:date=`%I:%M %P`]]
      


      You could also do this with just one field, but presumably you have reasons to want them separate. [ed. note: esnyder last edited this post 14 years, 5 months ago.]
        • 26503
        • 620 Posts
        Yes - I've tried converting an epoch date as well... no luck. still just returns the epoch year!

        here's something funny, I just tried:
        <h4>[[*publishedon:date=`%A %B %e %Y`]]</h4>
        , it returns: "Thursday January 1 1970" as well!!

        something is screwy. [ed. note: sean69 last edited this post 14 years, 5 months ago.]
          *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

          Sean Kimball CLP, CLS.
          Technical Director / Sr. Developer | BigBlock Studios
          ._______________________________________________.
          Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
          27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
          phone/fax: 905-426-5525
          • 9102 ☆ A M B ☆
          • 318 Posts
          That's odd -- I just tested the code I posted and it works for me. I edited the post to get the time format correct, I had it completely wrong the first time.

          Maybe verify that just converting to epoch time actually works, that is, look at the output of
          [[+startdate:strtotime]]
          

          And verify that is correct.
            • 9102 ☆ A M B ☆
            • 318 Posts
            Did you try the exact code I posted? You need to put the strtotime modifier first, before the date modifier.
              • 26503
              • 620 Posts
              No I didn't initially, I had changed the dates in the database to epoch times & changed the column type...

              Your EXACT code DOES work however.. Thanks!

              I don't remember ever having to do that before and the docs on output modifiers certainly don't reflect that unless you follow the 'Date Formats' link, the example they give is wrong here: http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters+(Output+Modifiers)
                *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                Sean Kimball CLP, CLS.
                Technical Director / Sr. Developer | BigBlock Studios
                ._______________________________________________.
                Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                phone/fax: 905-426-5525
                • 9102 ☆ A M B ☆
                • 318 Posts
                Yeah, that always seemed odd to me too -- that you have to apply another filter first in order for the date filter to work. It would be better if the date filter would check if the date is in epoch format, and convert it if it is not, that way this code would still work, and the date filter would work on its own.

                Glad you got it working!
                  • 26503
                  • 620 Posts
                  ha.. yea, it would be best if it were documented better smiley

                  I find it really strange that if I give the date =`` modifier an epoch formatted date to start with, that it still chokes... must be a bug of some sort.

                  oh well, it works now.
                    *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                    Sean Kimball CLP, CLS.
                    Technical Director / Sr. Developer | BigBlock Studios
                    ._______________________________________________.
                    Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                    27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                    phone/fax: 905-426-5525
                    • 3749
                    • 24,544 Posts
                    I think the reason that's necessary is that whatever you're using to set the placeholders (getResources?) converts the date placeholders to a time string, so if you're going to do your own formatting, you need to convert them back to unix timestamps with :strtotime. If your placeholder contained a raw unix timestamp, your original code would work.


                    ------------------------------------------------------------------------------------------
                    PLEASE, PLEASE specify the version of MODX you are using.
                    MODX info for everyone: http://bobsguides.com/modx.html
                      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
                      • 26503
                      • 620 Posts
                      Not sure where/if it is getting reformatted? All I am doing is pulling the values from a custom table & outputting to a chunk:

                      $attribs = $artistAttribs->getMany('ArtistGigs');
                      						
                      	foreach ($attribs as $attrib) {
                      		$aarray = $attrib->toArray();
                      		$output .= $this->modx->getChunk('ArtistGigRow',$aarray);
                      	}
                      						
                      	return $output;
                      
                        *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                        Sean Kimball CLP, CLS.
                        Technical Director / Sr. Developer | BigBlock Studios
                        ._______________________________________________.
                        Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                        27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                        phone/fax: 905-426-5525