We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    I tried this on my server, and it worked fine (my server offset is set to +2 hours)
    $dateFormat = '%B %e, %Y';
    $dateUnixTime = time();
    echo  strftime($dateFormat, (intval($dateUnixTime) + (2*60*60)));
    
      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
      • 36592
      • 970 Posts
      Quote from: cbaone at Jul 03, 2008, 02:01 AM

      Besides, the reflect snippet is outputting 1969 also and I don’t know of any PHx modifiers that’ll work on that.
      Be careful... reflect snippet has a bug when it is used with &dateSource.
      https://mirror3.cvsdude.com/trac/ditto/codebase/ticket/89
        • 4749
        • 623 Posts
        @sottwell:
        I created the file and it output the date just fine.

        @tkfm:
        I applied the &dittoSnippetParameters=`parents:44|sortBy:pub_date` fix and all is well. Thanks for the heads up!

        HOWEVER, even though I’m using PHx to format the date and the Reflect workaround does not mean that the problem is "fixed" at all. They’re just workarounds to a bigger problem. This will do for now, but I’m not going to call this one solved! I hope everyone can appreciate that.

        I really appreciate everyone’s insight and help. This community is the biggest reason I chose ModX over many other CMSs.


          The MODx has you...
          Utah Web Design
          • 11678
          • 160 Posts
          Susan; ;
          Thanks for putting me on the right track with that little php snip.
          I needed a way to parse out the date to put into a blog entry date box.
          What I did is take your php code and turn it into 3 handy snippets;
          getDay
          getDay
          <?php
          	$time = time();
          	$day = date('d',$time);
          	echo $day;
          ?>


          getMonth
          getMonth
          <?php
          	$time = time();
          	$month = date('m',$time);
          	echo $month;
          ?>


          getYear
          getYear
          <?php
          	$time = time();
          	$year = date('Y',$time);
          	echo $year;
          ?>


          I needed a text abbreviation of the month so I made another snippet to turn the number into text

          abvTextMonth
          <?php
          $time = time();
          $curMonth = date('m',$time);
          switch($curMonth){
          	case 01:    
          		$output='Jan';
          		break;
          	case 02:    
          		$output='Feb';
          		break;
          	case 03:    
          		$output='Mar';
          		break;
          	case 04:    
          		$output='Apr';
          		break;
          	case 05 :    
          		$output='May';
          		break;	
          	case 06:    
          		$output='Jun';
          		break;	
          	case 07:    
          		$output='Jul';
          		break;	
          	case 08:    
          		$output='Aug';
          		break;	
          	case 09:    
          		$output='Sep';
          		break;	
          	case 10 :    
          		$output='Oct';
          		break;	
          	case 11 :    
          		$output='Nov';
          		break;
          	case 12 :    
          		$output='Dec';
          		break;
          }
          return $output;
          ?>

          works like a charm in my blog template - see the image below.

          code fragment from my blog summary template using the above code to put the date in a box.
          <div class='date'>[!abvTextMonth!]<span>[!getDay!]</span>[!getYear!]</div>


          Thanks for your help.
          Hal


















            "Today’s headlines are nothing more than whispers of history"
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            date('M', time())

            also produces a short textual version of the month name.

            http://www.php.net/date
              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
              • 11678
              • 160 Posts
              Susan; Thanks again! I keep going through these cycles of having to re-learn all the php and mysql stuff. Should have known there was an easier way than I was doing it. Re-inventing the wheel again. Dang!
                "Today’s headlines are nothing more than whispers of history"
                • 11678
                • 160 Posts
                Susan; Could you show me how to put the abbreviated month into this scrap of a template where I presently am using [!getMonth!] ?

                <div class="date">[!getMonth!]<span>[!getDay!]</span>[!getYear!]</div>
                		    <h4 class="post-title"><a href="[~[+id+]~]" title="[+title+]" [+title+]</h4>


                I’ve tried to use the info on date(’M’) as above with no luck.
                Thanks
                Hal
                  "Today’s headlines are nothing more than whispers of history"
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  return date('M', time());
                  
                    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