Hi, so I’m using this part of code to show post time. I don’t know the reason but it shows yrs,months,weeks,days and hours only. I cannot get seconds and minutes to be readable by human. I use this in wordpress plugin where comment has a timestamp. Any ideas on solving this issue?
<?php
ob_start();
function last_comment_time(){
global $post;
$timestamp=get_post_meta($post->ID,"qya_last_post_posted",true);
if($timestamp==""){
echo "effekt yoxdur";
}else{
echo "sonuncu effekt".readable_time($timestamp,1)." ago";
}
}
function get_last_comment_time($extra=""){
global $post;
if($extra=="timestamp"){
return get_post_meta($post->ID,"qya_last_post_posted",true);
}else{
$ytime=get_post_meta($post->ID,"qya_last_post_posted",true);
return readable_time($ytime,1);
}
}
function get_post_start_time($extra=""){
global $post;
if($extra=="timestamp"){
return strtotime($post->post_date);
}else{
$xtime=strtotime($post->post_date);
return readable_time($xtime,1);
}
}
function readable_time($timestamp, $num_times = 2)
{
//this returns human readable time when it was uploaded (array in seconds)
$times = array(31536000 => 'il', 2592000 => 'ay', 604800 => 'həftə', 86400 => 'gün', 3600 => 'saat', 60 => 'dəqiqə', 1 => 'saniyə');
$now = time();
$secs = $now - $timestamp;
$count = 0;
$time = '';
foreach ($times AS $key => $value)
{
if ($secs >= $key)
{
//time found
$s = '';
$time .= floor($secs / $key);
if ((floor($secs / $key) != 1))
$s = '';
$time .= ' ' . $value . $s;
$count++;
$secs = $secs % $key;
if ($count > $num_times - 1 || $secs == 0)
break;
else
$time .= ', ';
}
}
return $time;
}
?>