Date Time Code

  Home arrow Date Time Code arrow DateSpan.php

By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2

    Table of Contents:



    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

    * (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

    * 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

    for($i=0; $i < 2; $i++)
    print("$date3 falls between $date1 and $date2 (inclusive)<br />");
    print("$date3 falls outside $date1 and $date2 (inclusive)<br />");

    <?php /*

    function dateBetween($start,$end,$theDate)
    return ($startES <= $findES && $findES <= $endES);

    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.

    More Date Time Code Articles
    More By Codewalkers

    blog comments powered by Disqus


    - DaysInSpan.php
    - MySQLdateSpan.php
    - DateSpan.php
    - FutureDateFormEntry.php
    - Generate Time Option List for Select stateme...
    - Current Age Script (v2)
    - class for some mysql imitated time functions
    - Current Age Script, up to the last day
    - filemtime_remote
    - Page Generation Time Figure-Outer
    - convGMT v2
    - Benchmarker
    - Simple PHP Calendar
    - Display message according to hour of day
    - Display Date Function

    Developer Shed Affiliates


    © 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap