hi efla.
This is a hacked version which has adaptation to both Y-m-d and d-m-Y.
(Of course, Y-n-j, Y/n/j, j-n-Y, j/n/Y are all OK).
But, short year (2 digits) and m-d-Y is no good.
That's because the script can't judge which field is year or month or date.
<?php
// $Id: modifier.ryus_date.php,v 1.1 2003/12/06 08:20:49 Ryuji Exp $
// FILE :: modifier.ryus_date.php
// AUTHOR :: Ryuji AMANO <info@joetsu.info>
// WEB :: Ryu's Planning <http://ryus.joetsu.info/>
//
function smarty_modifier_ryus_date($string, $format="", $withNew = true)
{
if($format != ""){
switch($format){
case "M":
$format = "n/j H:i";
break;
case "S":
$format = "n/j";
break;
default:
}
}
//global $xoopsUser;
$now = xoops_getUserTimestamp(time(), "");
if($string != '') {
if( preg_match( '/^([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})(.*)$/' , $string , $matches ) ) {
$time = strtotime( "{$matches[3]}-{$matches[2]}-{$matches[1]} {$matches[4]}" ) ;
} else {
$time = strtotime($string);
}
}else{
return;
}
if($withNew){
$NewMarks = array(
1*60*60*24 => ' <span class="new1">New!</span>',
7*60*60*24 => ' <span class="new2">New</span>'
);
$erapse = $now - $time;
$new = "";
foreach ($NewMarks as $limit=>$tag) {
if ($erapse <= $limit){
$new .= $tag;
break;
}
}
}else{
$new = "";
}
if($format == ""){
$retvar = $string . $new;
}elseif(strtolower($format) == "new"){
$retvar = $new;
}else{
$retvar = date($format, $time) . $new;
}
return $retvar;
}
?>