w3resource
php Programming Exercies

PHP Date Exercises : Check whether the given dates are valid or not

PHP date: Exercise-10 with Solution

Write a PHP script to check whether the given dates are valid or not?

Sample Solution:

PHP Code:

<?php
var_dump(checkdate(2, 30, 2008));
var_dump(checkdate(2, 29, 2008));
?>

Sample Output:

bool(false)                                                 
bool(true)

Flowchart :

Flowchart: Check whether a given dates is valid or not

PHP Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a PHP script to print like : Saturday the 7th
Next: Write a PHP script to get time difference in days and years, months, days, hours, minutes, seconds between two dates.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming