Time stamps

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KoRnDragon

    #1

    Time stamps

    Does anyone know of a script that translates time stamps to look like
    those used by Gmail? (ie. 2 days ago/ 15 minutes ago etc.)

  • Zilla

    #2
    Re: Time stamps

    KoRnDragon wrote:[color=blue]
    > Does anyone know of a script that translates time stamps to look like
    > those used by Gmail? (ie. 2 days ago/ 15 minutes ago etc.)
    >[/color]

    With time() you can get the current timestamp and then you can calculate
    the difference in minutes or days or weeks etc.

    Zilla.

    Comment

    • Dawsons

      #3
      Re: Time stamps

      function sec2text($secs) {
      $units = array(
      86400 => 'Days',
      3600 => 'Hours',
      60 => 'mins',
      1 => 'secs' );

      $out = '';
      foreach($units as $unit => $txt ) {
      $t = floor($secs / $unit);
      if( $t > 0 ) {
      $secs -= ($t * $unit );
      $out .= $t . ' ' . $txt . ' ';
      }
      }
      return $out;
      }

      // behind count
      $behind = time() - $take;

      sec2text($behin d)

      -----------------------------------------------------------

      Obviously the $take function is the anmount of time your taking away rom the
      current time

      hope this helps

      Stuart


      "KoRnDragon " <korndragon@gma il.com> wrote in message
      news:1139863934 .425246.83540@g 14g2000cwa.goog legroups.com...[color=blue]
      > Does anyone know of a script that translates time stamps to look like
      > those used by Gmail? (ie. 2 days ago/ 15 minutes ago etc.)
      >[/color]


      Comment

      Working...