Simple function to check if a given date falls within a given time span.
Code contains a fully functional illustrative example. Just change the commenting as instructed in the file to run the example. It's a matter of changing a single character (from '/' to '*').
Useful for determining, say, if a date a user has entered falls during your vacation?;)
By : dsilvia
<?php /* * (c) 2006, D.E. Silvia, All rights reserved. * This code is available for use for non-commercial purposes. * Free to distribute as long as this copyright information remains intact. * No modification is authorized. Please, refer bugs/enhancements to * dsilvia@mchsi.com * */
/* * Simple function to check if a given date falls within a given time span. * * Arguments are arrays of the form array(dayNum,monthNum,yearNum) as recognized * by the standard php function mktime(). * * Example: * A simple illustrator to show how the functions are used. * * btw, ES|es stands for 'Epoch Seconds' * replace first character, single line comment character slash ('/'), with multiline comment character star ('*') in the line below to use the test code //?>
function dateAryEStime($theDate) { return dateEStime($theDate[0],$theDate[1],$theDate[2]); }
function dateEStime($theDay,$theMonth,$theYear) { return mktime(0,0,0,$theMonth,$theDay,$theYear); } ?>
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.