https://stackoverflow.com/questions/13194322/php-regex-to-check-date-is-in-yyyy-mm-dd-format
http://thisinterestsme.com/calculating-difference-dates-php/
$date="2012-09-12";
if (preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$date)) {
return true;
} else {
return false;
}
http://thisinterestsme.com/calculating-difference-dates-php/
<?php
//Our "then" date.
$then = "2009-02-04";
//Convert it into a timestamp.
$then = strtotime($then);
//Get the current timestamp.
$now = time();
//Calculate the difference.
$difference = $now - $then;
//Convert seconds into days.
$days = floor($difference / (60*60*24) );
echo $days;
No comments:
Post a Comment