Get Thunderbird! Firefox 2

Misc. Stats For This Page

Operating Systems
Linux
Windows
Mac
Other

Browsers
Firefox
MSIE
Netscape
AOL
Safari
Opera
MSN
Search Bots
Other

Google
Web www.ckorp.net
Page loads - 1415.
This page last modified on 01 Nov 2007
Click here for your favorite eBay items Foxkeh banners for Firefox 2
.t.r.a.n.s.p.a.r.e.n.t.  .i.m.a.g.e.s.

Sec2Time(INT)

Function that takes an integer representing a length of time in seconds. Returns an associative array containing the number of years, days, minutes, and seconds in the time provided.
Seconds to analyze:


Here is the code:
<?php
function Sec2Time($time){
  if(
is_numeric($time)){
    
$value = array(
      
"years" => 0"days" => 0"hours" => 0,
      
"minutes" => 0"seconds" => 0,
    );
    if(
$time >= 31556926){
      
$value["years"] = floor($time/31556926);
      
$time = ($time%31556926);
    }
    if(
$time >= 86400){
      
$value["days"] = floor($time/86400);
      
$time = ($time%86400);
    }
    if(
$time >= 3600){
      
$value["hours"] = floor($time/3600);
      
$time = ($time%3600);
    }
    if(
$time >= 60){
      
$value["minutes"] = floor($time/60);
      
$time = ($time%60);
    }
    
$value["seconds"] = floor($time);
    return (array) 
$value;
  }else{
    return (bool) 
FALSE;
  }
}
?>