Advertisement
WILDAN_IZZUDIN

TIME AGO

Nov 7th, 2018
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <?php
  2. /* PHP Script
  3. PHP Time Ago
  4. Created By Wildan Izzudin.
  5.     (c) 2019 Underxploit
  6. */
  7. function yl($str) {
  8.     $est = time() - $str;
  9.     if ($est < 1) {
  10.         return 'kurang dari 1 detik';
  11.     }
  12.  
  13.     $def = array(
  14.         12 * 30 * 24 * 60 * 60 => 'tahun',
  15.         30 * 24 * 60 * 60 => 'bulan',
  16.         24 * 60 * 60 => 'hari',
  17.         60 * 60 => 'jam',
  18.         60 => 'menit',
  19.         1 => 'detik'
  20.     );
  21.     foreach($def as $secs => $str) {
  22.         $d = $est / $secs;
  23.         if ($d >= 1) {
  24.             $r = round($d);
  25.             return $r . ' ' . $str . ($r > 1 ? '' : '') . ' yang lalu';
  26.         }
  27.     }
  28. }
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement