Home  >  Article  >  Backend Development  >  PHP verify the validity of time_PHP tutorial

PHP verify the validity of time_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:29:011218browse

PHP has a built-in function to verify the validity of the date, namely the checkdate function. Let’s share the definition and usage of the checkdate function.

checkdate definition and usage

The checkdate() function verifies a Gregorian date. The function returns true if the specified value is legal, false otherwise.

Dates are legal if:

month is between and including 1 - 12

The value of Day is within the range of days that a given month should have, taking leap years into account.

year is between and including 1 to 32767

checkdate syntax

checkdate(month,day,year)

month required. Specified month.

day required. Specified day.

year required. Specified year.

Usage examples are as follows:

<?php
var_dump(checkdate(12,31,2000));
var_dump(checkdate(2,29,2003));
var_dump(checkdate(2,29,2004));

The result will be output:

bool(true)
bool(false)
bool(true)

Articles you may be interested in

  • Javascript method to verify date and time validity
  • PHP verification email correctness and validity
  • A summary of methods to get time intervals in PHP, a complete method of PHP displaying forum posting time intervals
  • A summary of PHP methods to get current time and timestamps
  • thinkphp automatic verification and auto-filling Invalid solution
  • php function to extract the birthday date from the ID number and verify whether it is a minor
  • php summary of N methods to get the timestamp of today, tomorrow and yesterday
  • How to get the start timestamp and end timestamp of today, yesterday, last week, and this month in php

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/779408.htmlTechArticlephp has a built-in function to verify the validity of the date, namely the checkdate function. Let’s share the definition and usage of the checkdate function. checkdate definition and usage checkdate() function verifies a grid...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn