Of course the user could select an invalid date, such as 30th february 2006, so I wanted to use checkdate to check that the date is valid before the date is stored in the mysql database.
My theory was to convert the date to a timestamp, and use a while loop to increment the date by 86400 seconds until a valid date was found.
However, I was playing around with some code and found that when converting an invalid date (like 30th feb 2006) to a time stamp, it actually comes out as 2nd march 2006, so my above theory for the code is not going to work.
Code: Select all
if(!checkdate($_POST['productStockDateM'], $_POST['productStockDateD'], $_POST['productStockDateY']))
{
$productStockDate = strtotime($_POST['productStockDateM'].'/'.$_POST['productStockDateD'].'/'.$_POST['productStockDateY']);
$productStockDate = $productStockDate + 86400;
echo strftime ( "%d-%m-%Y", $productStockDate );
}