<![CDATA[ Changing format of publishedon date - My Forums]]> https://forums.modx.com/thread/?thread=13979 <![CDATA[Re: Changing format of publishedon date]]> https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=3#dis-post-468955 http://stackoverflow.com/questions/2915864/php-how-to-find-the-time-elapsed-since-a-date-time]]> BobRay Jun 13, 2013, 05:41 AM https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=3#dis-post-468955 <![CDATA[Re: Changing format of publishedon date]]> https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=3#dis-post-468947
What if I want to rather state the number of minutes, second, months, weeks, days and years ago. Like 40 minutes ago, 2 years ago, etc? This is how the MODx Forum date is formatted.]]>
ojchris Jun 13, 2013, 02:24 AM https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=3#dis-post-468947
<![CDATA[Re: Changing format of publishedon date]]> https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=3#dis-post-76901
]]>
BobRay Mar 01, 2011, 11:25 PM https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=3#dis-post-76901
<![CDATA[Re: Changing format of publishedon date]]> https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=3#dis-post-76900
<?php
/* DateSuffix snippet */

$suffix = '';
$first_digit = substr($input, -8, 1);
$second_digit = substr($input, -7, 1);
$original_number = $first_digit . $second_digit;
  
switch ($second_digit) {

  case 1:
  $suffix = 'st';
  break;
  
  case 2:
  $suffix = 'nd';
  break;
  
  case 3:
  $suffix = 'rd';
  break;
  
  default:
  $suffix = 'th';
}

/* handle anomalies */
switch ($original_number) {

  case 11:
  case 12:
  case 13:
    $suffix = 'th';
    break;

}

  $new_number = ltrim($original_number, '0') . $suffix;
  
return str_replace($original_number.',', $new_number . ',', $input);


Thanks again for your help! smiley]]>
polrbear Mar 01, 2011, 03:54 PM https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=3#dis-post-76900
<![CDATA[Re: Changing format of publishedon date]]> https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=3#dis-post-76899
return str_replace(',', ',' . $suffix, $input);


Add the custom filter to the end of the chain.
]]>
BobRay Mar 01, 2011, 02:51 PM https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=3#dis-post-76899
<![CDATA[Re: Changing format of publishedon date]]> https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=2#dis-post-76898 Quote from: BobRay at Oct 29, 2010, 04:16 AM

Just tack on laughateSuffix after date: (assuming that the number you want to suffix is at the end).

I’m back grin

Just 4 months later, I finally got around to trying to use this - and immediately ran into a problem: I have no idea how to attach this:
[[+publishedon:strtotime:date=`%B %d, %Y`]]

to this:
:DateSuffix


Particularly when the number needing the suffix isn’t at the end. huh Sorry to have to ask for hand-holding all the way, but I am really new to the whole snippet modifiers thing. Thanks!]]>
polrbear Feb 25, 2011, 10:40 PM https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=2#dis-post-76898
<![CDATA[Re: Changing format of publishedon date - Multilingual?]]> https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=2#dis-post-76897
is it also possible to use
setlocale(LC_ALL, 'nl_NL')
within a filter?


[[+publishedon:strtotime:date=`%d %b %Y`]]

that would be handy for multilingual sites.

Ralph]]>
rdaneeel Jan 26, 2011, 10:09 AM https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=2#dis-post-76897
<![CDATA[Re: Changing format of publishedon date]]> https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=2#dis-post-76896
At least I know I’m not going crazy.

I’m guessing that it might then work when I upload the test site from my windows localhost to the linux server then.

Thanks for your tutorials and info pages - they are very helpful for non-programmer types like me.]]>
robinqld Dec 18, 2010, 05:25 AM https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=2#dis-post-76896
<![CDATA[Re: Changing format of publishedon date]]> https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=2#dis-post-76895
http://www.php.net/manual/en/function.strftime.php]]>
BobRay Dec 17, 2010, 10:56 PM https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=2#dis-post-76895
<![CDATA[Re: Changing format of publishedon date]]> https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=2#dis-post-76894
I’ve run into one glitch - including the %e parameter results in a blank output. The %e is meant to remove the leading zero on the %d parameter. It’s not major, but puzzling.

eg.
[[*publishedon:strtotime:date=`%e %B %Y`]]
produces no output but
[[*publishedon:strtotime:date=`%d %B %Y`]]
does.

Could it be some error in my configuration or is this a bug?]]>
robinqld Dec 17, 2010, 07:28 PM https://forums.modx.com/thread/13979/changing-format-of-publishedon-date?page=2#dis-post-76894