// SMART DATE
function veronika_smart_date( $time ) {
$time_diff = round(abs(time() - strtotime( $time )) / 60);
$time_diff_h = floor($time_diff/60);
$time_diff_d = floor($time_diff/1440);
$time_diff_w = floor($time_diff/10080);
$time_diff_m = floor($time_diff/43200);
$time_diff_y = floor($time_diff/518400);
if($time_diff < 2) {
$time_diff_name = __('minute ago', 'veronika');
} else if ($time_diff < 60) {
$time_diff_name = sprintf(__('%d minutes ago', 'veronika'), $time_diff);
} else if ($time_diff < 120) {
$time_diff_name = sprintf(__('%d hour ago', 'veronika'), $time_diff_h);
} else if ($time_diff < 1440) {
$time_diff_name = sprintf(__('%d hours ago', 'veronika'), $time_diff_h);
} else if ($time_diff < 2880) {
$time_diff_name = sprintf(__('%d day ago', 'veronika'), $time_diff_d);
} else if ($time_diff < 10080) {
$time_diff_name = sprintf(__('%d days ago', 'veronika'), $time_diff_d);
} else if ($time_diff < 20160) {
$time_diff_name = sprintf(__('%d week ago', 'veronika'), $time_diff_w);
} else if ($time_diff < 43200) {
$time_diff_name = sprintf(__('%d weeks ago', 'veronika'), $time_diff_w);
} else if ($time_diff < 86400) {
$time_diff_name = sprintf(__('%d month ago', 'veronika'), $time_diff_m);
} else if ($time_diff < 518400) {
$time_diff_name = sprintf(__('%d months ago', 'veronika'), $time_diff_m);
} else if ($time_diff < 1036800) {
$time_diff_name = sprintf(__('%d year ago', 'veronika'), $time_diff_y);
} else {
$time_diff_name = sprintf(__('%d years ago', 'veronika'), $time_diff_y);
}
return $time_diff_name;
}