wp_checkdate

Test if the supplied date is valid for the Gregorian calendar.

Description

wp_checkdate( (int) $month, (int) $day, (int) $year, (string) $source_date ); 

Parameters (4)

0. $month (int)
Month number.
1. $day (int)
Day number.
2. $year (int)
Year number.
3. $source_date (string)
The date to filter.

Usage

  1. if ( !function_exists( 'wp_checkdate' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // Month number. 
  5. $month = -1; 
  6.  
  7. // Day number. 
  8. $day = -1; 
  9.  
  10. // Year number. 
  11. $year = -1; 
  12.  
  13. // The date to filter. 
  14. $source_date = ''; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = wp_checkdate($month, $day, $year, $source_date); 
  18.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function wp_checkdate( $month, $day, $year, $source_date ) { 
  2. /** 
  3. * Filters whether the given date is valid for the Gregorian calendar. 
  4. * @since 3.5.0 
  5. * @param bool $checkdate Whether the given date is valid. 
  6. * @param string $source_date Date to check. 
  7. */ 
  8. return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date );