I am trying to format the date multiple times on each article. It looks like I can only have one date format at a time and still limited to strfrtime (no - st, nd, rd). Is there a way to format using EVAL?
FROM:
<div class="eventdate">
<p class="month">SEP</p>
<p class="day">18th</p>
<p class="year">2007</p>
</div>
TO:
<div class="eventdate">
<p class="month">[+date+]</p>
<p class="day">[+date+]</p>
<p class="year">[+date+]</p>
</div>
I am going publish "empty" articles to create a simple calendar and would like to have the expire on the day after they are over.
Is there a better solution?
DropboxUploader -- Upload files to a Dropbox account.
DIG -- Dynamic Image Generator
gus -- Google URL Shortener
makeQR -- Uses google chart api to make QR codes.
MODxTweeter -- Update your twitter status on publish.
Thanks for the help!
I am guessing strftime is used for better localization.
Home much overhead would I be creating to apply a function?
function ordinal($cardinal){
$test_c = abs($cardinal) % 10;
$ext = ((abs($cardinal) %100 < 21 && abs($cardinal) %100 > 4) ? ’th’
: (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1)
? ’th’ : ’st’ : ’nd’ : ’rd’ : ’th’));
return $cardinal.$ext;
}
I think my site might go international anyway... I should probably drop formatting.
DropboxUploader -- Upload files to a Dropbox account.
DIG -- Dynamic Image Generator
gus -- Google URL Shortener
makeQR -- Uses google chart api to make QR codes.
MODxTweeter -- Update your twitter status on publish.
Worked like a charm!
<p class="day">[+unpub_date:date=`%d`:ordinal+]</p>
phx:ordinal
<?php
if (!function_exists('ordinal'))
{
function ordinal($cardinal){
$test_c = abs($cardinal) % 10;
$ext = ((abs($cardinal) %100 < 21 && abs($cardinal) %100 > 4) ? 'th'
: (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1)
? 'th' : 'st' : 'nd' : 'rd' : 'th'));
return $cardinal.$ext;
}
}
return ordinal($output);
?>
DropboxUploader -- Upload files to a Dropbox account.
DIG -- Dynamic Image Generator
gus -- Google URL Shortener
makeQR -- Uses google chart api to make QR codes.
MODxTweeter -- Update your twitter status on publish.
-
MODX Staff
- 2,502 Posts
bwente,
This is a very nice little snippet. You should add that to the PHx wiki page. This would actually be very handy as would the ability to drop the zero in the hours from the unixtime output from strftime().
Cheers,
Jay
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub
DropboxUploader -- Upload files to a Dropbox account.
DIG -- Dynamic Image Generator
gus -- Google URL Shortener
makeQR -- Uses google chart api to make QR codes.
MODxTweeter -- Update your twitter status on publish.