Another function I constantly check on and use, especially when dealing with dates, working out if one has passed usually. The function mktime() does this simply. Let's say you've got a form, 3 select boxes, one for each of the day, month and year (never rely on people inputting the date in the correct format for you, always control it!). So you take in 3 POST variables, to calculate whether it's before or after today you just need the following:
$givendate = mktime(0, 0, 0, $_POST['month'], $_POST['day'], $_POST['year']);
$today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
if ($givendate < $today) {
print "The date has passed";
} else {
print "The date hasn't passed";
}
?>
Yes there are a far wider range of uses for this functions, but it's one I constantly use for the reason above (well I use it a little more advanced than that but it's basically the same!).








