Here the date action function has an increase in time, calculated the date given is the day of the week, check the date is valid date time comparison function, return two date difference a few seconds, a few minutes, a few hours or a few days
<?php
function DateAdd ($date, $int, $unit = "D") {
The increase in time (can also be improved as time and seconds can be increased, there is time to fill up)
$datearr = Explode ("-", $date);
$value [$unit] = $int;
//
Return date ("Y-m-d", Mktime (0,0,0, $datearr [1] + $value [' m '], $datearr [2] + $value [' d '], $datearr [0] + $value [' y ']));
Cloud Habitat Community Network
}
function Getweekday ($date) {//Calculate the date given is the day of the week
$datearr = Explode ("-", $date);
Return Date ("W", Mktime (0,0,0, $datearr [1], $datearr [2], $datearr [0]));
//
}
?>
?
function Check_date ($date) {//check date is legal date
$datearr = Explode ("-", $date);
if (is_numeric ($datearr [0]) && is_numeric ($datearr [1]) && is_numeric ($datearr [2])) {//cloud-Habitat Community Network
return Checkdate ($datearr [1], $datearr [2], $datearr [0]);
}
return false;
}
function Check_time ($time) {//Check time is legal time
Cloud Habitat Community Network
$timearr = Explode (":", $time);
if (is_numeric ($timearr [0]) && is_numeric ($timearr [1]) && is_numeric ($timearr [2])) {
//
if ($timearr [0] >= 0 && $timearr [0] <=) && ($timearr [1] >= 0 && $timearr [1] <= 59) && ($timearr [2] >= 0 && $timearr [2] <= 59))
Php
return true;
Else
return false;
}
return false;
}
function DateDiff ($date 1, $date 2, $unit = "") {
A time comparison function that returns two dates, a few seconds, minutes, hours, or days.
//
Switch ($unit) {
Case ' s ':
$dividend = 1;
Break
Case ' I ':
$dividend = 60;
break;
case ' h ':
$dividend = 3600;
break;
case ' d ':
$dividend = 86400;
break;//
default:
$dividend = 86400;
}
$time 1 = strtotime ($date 1);
$time 2 = strtotime ($date 2);
if ($time 1 && $time 2)//
return (float) ( $time 1-$time 2)/$dividend;
return false;
}