Php Getting Started Tutorial (21) php date and time functions

Source: Internet
Author: User
Php Getting Started Tutorial (21) php date and time functions

  1. Echo time (); /// return "1264668961"
  2. ?>

2, date ()

The date () function is required to convert the UNIX timestamp to the readable current time.

The prototype of the date function is as follows:

  1. Echo date ("Y/m/d ");
  2. Echo"
    ";
  3. Echo date ("Y. m. d ");
  4. Echo"
    ";
  5. Echo date ("Y-m-d ");
  6. ?>

Output: 2013/11/212013.11.212013-11-21

3. the mktime () function returns the Unix timestamp of a date.

Parameter description:

  1. Echo (date ("M-d-Y", mktime )));
  2. Echo (date ("M-d-Y", mktime )));
  3. Echo (date ("M-d-Y", mktime )));
  4. Echo (date ("M-d-Y", mktime )));
  5. ?>

Output: The Jan-05-2002Feb-01-2002Jan-01-2001Jan-01-1999 4, checkdate () function verifies a greaguri date. If the specified value is valid, the function returns true; otherwise, false. The date is valid in the following cases: the value of month between and including 1-12 days is within the range of days that a given month should have, and the leap year has been taken into account. Year is between and includes the syntax checkdate (month, day, year) parameter from 1 to 32767

  1. Var_dump (checkdate (12, 31, 2000 ));
  2. Var_dump (checkdate (2003 ));
  3. Var_dump (checkdate (2004 ));
  4. ?>

Output: bool (true) bool (false) bool (true)

>>> View more php tutorials <

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.