PHP 24-hour timing method Time implementation program. How does PHP obtain the 24-hour timer time? You can use a custom function provided in this article to obtain the current time and use the 24-hour time calculation method. The code is as follows: how does one obtain the 24-hour timer Time by copying the code on behalf of PHP? You can use a custom function provided in this article to obtain the current time and use the 24-hour time calculation method.
| The code is as follows: |
|
|
Function getTime (){
$ Time = "";
// Morning time
$ H1 = date ("h")> 12? (Date ("h")-12): date ("h ");
// Afternoon time
$ H2 = (date ("h") + 12)> = 24 )? Date ("h") :( date ("h") + 12 );
// Determine whether it is morning
If (date ("a") = "am "){
$ Time = date ("Y-m-d $ h1: I: s ");
} Else {// determines whether it is afternoon
$ Time = date ("Y-m-d $ h2: I: s ");
}
Return $ time;
} |
Why? You can use a custom function provided in this article to obtain the current time and use the 24-hour time calculation method. The code is as follows...