relative date by Levani plugin
-
I installed easy relative date plugin on my wp installation and everything is fine. Plug in works ok but has problem tracking seconds…
Better:
If I add a news, then in the date field should appear 1 second ago, 2 seconds ago, etc… instead, the plugin shows something like -2589 second ago, -2128 seconds ago and so…. I tried to hard coding easy_relative_date.php but without success.
Here is the code of easy_relative_date.php im’ currently using:
?<?php load_plugin_textdomain('erd', PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)).'/languages'); if(!function_exists('easy_relative_date')){ function easy_relative_date($timestamp){ $difference = time() - $timestamp; if($difference >= 60*60*24*365){ // if more than a year ago $int = intval($difference / (60*60*24*365)); $r = printf(__ngettext("%d anno fa", "%d anni fa", $int, 'erd'), $int); } elseif($difference >= 60*60*24*7*5){ // if more than five weeks ago $int = intval($difference / (60*60*24*30)); $r = printf(__ngettext("%d mese fa", "%d mesi fa", $int, 'erd'), $int); } elseif($difference >= 60*60*24*7){ // if more than a week ago $int = intval($difference / (60*60*24*7)); $r = printf(__ngettext("%d settimana fa", "%d settimane fa", $int, 'erd'), $int); } elseif($difference >= 60*60*24){ // if more than a day ago $int = intval($difference / (60*60*24)); if ($int == 1) { $r = _e("Ieri", 'erd'); } else { $r = printf(__("%d giorni fa", 'erd'), $int); } } elseif($difference >= 60*60){ // if more than an hour ago $int = intval($difference / (60*60)); $r = printf(__ngettext("%d ora fa", "%d ore fa", $int, 'erd'), $int); } elseif($difference >= 60){ // if more than a minute ago $int = intval($difference / (60)); $r = printf(__ngettext("%d minuto fa", "%d minuti fa", $int, 'erd'), $int); } else //count seconds { $s = $difference >= 1 ? 's' : ''; $r = printf(__ngettext("%d secondo fa", "%d secondi fa", $difference, 'erd'), $difference); } } } ?>
Any idea how to fix this problem? Thany you!
- The topic ‘relative date by Levani plugin’ is closed to new replies.