この便利な関数は、秒で表されるイベントを年、月、日、時などの時間形式に変換できます。
- function Sec2Time($time){
- if(is_numeric($time)){
- $value = array(
- "年" => 0, "日" => 0, "時間" => 0,
- "分" => 0, "秒" => 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"] =フロア ($time/3600);
- $time = ($time%3600);
- }
- if($time >= 60){
- $value["分"] = フロア($time/60);
- $ time = ($time%60);
- }
- $value["秒"] = Floor($time);
- return (配列) $value;
- }else{
- return (bool) FALSE;
- }
- }
コードをコピー
|