PHP Time function usage analysis, PHP function Usage _php Tutorial

Source: Internet
Author: User
Tags php database php regular expression

PHP Time function usage analysis, PHP function usage


The example in this article describes the PHP time function usage. Share to everyone for your reference, as follows:

PHP has a UNIX timestamp related operation function, easy to use

Time () returns the current Unix timestamp

Microtime--Returns the current Unix timestamp and number of microseconds

Example 1. Run timings for scripts with Microtime ()

<?php/*** simple function to replicate PHP 5 behaviour*/function microtime_float () {  list ($usec, $sec) = Explode ("" , Microtime ());  return (float) $usec + (float) $sec);} $time _start = Microtime_float (),//Sleep for a whileusleep (+), $time _end = Microtime_float (), $time = $time _end-$time _st Art;echo "did nothing in $time seconds/n";? >

Mktime () Gets a date for the Unix timestamp

int mktime ([int hour [, int minute [, int second [, int month [, int day [, int year [, int IS_DST]]] []]

Parameters can be omitted from right to left, and any omitted parameters are set to the current value of the cost date and time

Date () format a local time/date

String date (string format [, int timestamp])

Tip: From PHP 5.1, the timestamp of the time the request was initiated was saved in $_server[' Request_time '.

Strtotime--Parse the datetime description of any English text into a Unix timestamp

Echo strtotime ("+1 Day"), "/n", Echo strtotime ("+1 Week"), "/n";

Example 2. A certain time after the day, after a month

Strtotime ("+1 Day". $day); Strtotime ("2008-01-31 +1 Month"), Strtotime ($day. "+1 Day");

The above forms are correct

PS: This site also provides a UNIX timestamp conversion tool, very practical, to provide you with reference:

Unix timestamp (timestamp) conversion tool:
Http://tools.jb51.net/code/unixtime

Here, we recommend a Web site of the PHP format beautification of the layout tools to help you in the future of PHP programming code layout:

PHP Code online format Beautification tool:

Http://tools.jb51.net/code/phpformat

In addition, because PHP is a C language style, the following tool can also be used to implement the PHP code format:

C Language Style/html/css/json code formatting beautification tool:
Http://tools.jb51.net/code/ccode_html_css_json

More interested in PHP related content readers can view the site: "PHP Math Skills Summary", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", "PHP array" operation Skills Daquan, " PHP Sorting algorithm Summary, "PHP Common traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", "PHP Programming Algorithm Summary", "PHP Regular Expression Usage summary", "PHP operation and operator Usage Summary", "PHP string Usage Summary" and " A summary of common PHP database operation techniques

I hope this article is helpful to you in PHP programming.

http://www.bkjia.com/PHPjc/1133058.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133058.html techarticle PHP Time function usage analysis, PHP function Usage This example describes the PHP time function usage. Share to everyone for your reference, as follows: PHP has a UNIX timestamp related operation function ...

  • 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.