hmmy Sunday 24th January 2016, 23:45:06
public static function toDate($id, $pattern = 'j M \'y')
{
global $lang;
$timestamp = strtotime(substr($id, 0, 16));
$diff = time() - $timestamp;
if($pattern === 'j M \'y' && $diff < 2628000) //1 week
{
$periods = array(604800 => 'w', 86400 => 'd', 3600 => 'h', 60 => 'm', 1 => 's');
foreach($periods as $key => $value)
{
if($diff >= $key)
{
$num = (int) ($diff / $key);
return $num. '' .$value. '';
}
}
}
if (date('Y') == date('Y', $timestamp)) {
return date('j M', $timestamp);
}
else
return date($pattern, $timestamp);
}
hmmy Monday 25th January 2016, 20:05:08
You might have to edit the post to view it; "Wink" is not part of the code. Think that's a smileyFred#f8768 Monday 25th January 2016, 21:59:46
Try this:
public static function toDate($id, $pattern = 'j M Y')
{
global $lang;
$timestamp = strtotime(substr($id, 0, 16));
$diff = time() - $timestamp;
if($pattern === 'j M Y' && $diff < 2628000) //1 week
{
$periods = array(604800 => 'w', 86400 => 'd', 3600 => 'h', 60 => 'm', 1 => 's');
foreach($periods as $key => $value)
{
if($diff >= $key)
{
$num = (int) ($diff / $key);
return $num.$value;
}
}
}
if (date('Y') == date('Y', $timestamp))
return date('j M', $timestamp);
else
return date($pattern, $timestamp);
}
Fred#f8768 Tuesday 26th January 2016, 09:31:32
Remove this on the $periods array():
, 3600 => 'h', 60 => 'm', 1 => 's'
Suggested Topics | View / Reply | Forum |
---|---|---|
hmmy started tips C07025 - Colored Tripcodes | 2.7K / 4 | Feature Requests |
Fred#4346f29d started plugin Signature | 1.6K / 3 | Resources |
333b98 started Problem with topics updating on topic view (most recent populates first) | 936 / 1 | Bug reports |
AlexanderLiebrecht started plugin Fred, how did you realize the Download Page here? | 1.1K / 1 | General Questions |