PHP converts second (non-timestamp) into hour and minute PHPCode website construction: www.ucantech.com & nbsp; convert second (non-timestamp) converted to ** hour ** & nbsp; functionsec2time ($ sec) {& nbsp; & PHP converts seconds (non-timestamp) into hours and minutes
PHP Code website construction: http://www.ucantech.com/
// Converts a second (non-timestamp) to ** hour **.
Function sec2time ($ sec ){
$ Sec = round ($ sec/60 );
If ($ sec> = 60 ){
$ Hour = floor ($ sec/60 );
$ Min = $ sec % 60;
$ Res = $ hour. 'hour ';
$ Min! = 0 & $ res. = $ min. 'minutes ';
} Else {
$ Res = $ sec. 'mine ';
}
Return $ res;
}
Time converted to day, hour, minute, second
Copy content from PHP Code to clipboard
Class FormatSeconds
{
Var $ days;
Var $ hours;
Var $ minutes;
Var $ seconds;
Function getDays ()
{
Return $ this-> days;
}
Function getHours ()
{
Return $ this-> hours;
}
Function getMinutes ()
{
Return $ this-> minutes;
}
Function getSeconds ()
{
Return $ this-> seconds;
}
Function FormatSeconds ($ sec)
{
$ This-> days = floor ($ sec/(24*3600 ));
$ Sec = $ sec % (24*3600 );
$ This-> hours = floor ($ sec/3600 );
$ RemainSeconds = $ sec % 3600;
$ This-> minutes = floor ($ remainSeconds/60 );
$ This-> seconds = intval ($ sec-$ this-> hours * 3600-$ this-> minutes * 60 );
}
}
$ Fs = new FormatSeconds (360000 );
Print $ fs-> getDays ();
Print "";
Print $ fs-> getHours ();
Print "";
Print $ fs-> getMinutes ();
Print ""; (fblww-0110)