How to implement the 24-hour timer in PHP _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.