You probably noticed that we have human friendly dates formatting here.
You can get the same to your websites if you take my get_date function code and replace the one you have in your /misc/fns.misc.php:
function get_date($timestamp, $format = "date")
{
global $SESSION;
$diff = $SESSION->conf['timezone']*60;
$datetime = $timestamp - (date("Z") - $diff) + (date("I") ? 3600 : 0);
$date = $SESSION->conf['timeformat'] ? date("m/d/Y", $datetime) : date("d/m/Y", $datetime);
$now = time();
$now = $now - (date("Z") - $diff) + (date("I") ? 3600 : 0);
$today = $SESSION->conf['timeformat'] ? date("m/d/Y", $now) : date("d/m/Y", $now);
$yesterday = $SESSION->conf['timeformat'] ? date("m/d/Y", $now-86400) : date("d/m/Y", $now-86400);
if ($date == $today)
$date = 'Today';
else if ($date == $yesterday)
$date = 'Yesterday';
if ( $format == "date" ) {
return $date;
}
elseif ( $format == "time" ) {
return ($SESSION->conf['timeformat'] ? date("h:i A", $datetime) : date("H:i", $datetime));
}
elseif ( $format == "rss" ) {
date("r", $datetime);
}
elseif ( $format == "full" ) {
return $date.' ' . ($SESSION->conf['timeformat'] ? date("h:i A", $datetime) : date("H:i", $datetime));
}
return;
}
// End function
This solution can be multi-language friendly if you use $LANG['core']['today'] instead of just 'Today'.
But don't forget to add $LANG to the 'global $SESSION' line.
By the way, you can set more appropriate date formatting for your country by using, for example, "d.m.Y" instead of "d/m/Y" inside this function if it's ok for you.







Comments
godyn
gugu
Log in to leave a comment