#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    How to check entered time range is in a given time range using php


    My question is how to add time range validations. user can add a 'task1' between 8.00am to 10.00 am so the time range is between 8.00am and 10.00am. I need to prevent user by entering next task between above time range. Maybe 'task2' start time is 8.30am and end time is 9.30am. Above time range is queried form database table. I tried to do that by using between clause, but at some point I stucked. so need your help. so can i do that? I tried searching all over and couldn't find any solution for that. hope you can my question you.

    query the database values from here Get the Previous values from Database
    PHP Code:
    $start=$val['starttime']; $end=$val['end']; 
    then get what user has entered.
    PHP Code:
    $start_time=$_POST['start_time']; $end_time=$_POST['end_time']; 
    this is the between that i tried.
    PHP Code:
    if((($start_time<=$start)&&($start>=$endtime))&&(($start_time<=$end)&& ($end>=$end_time)) {      echo "<script>location.replace(\"test.php?msg=cannot enter another task in  the same time period\");</script>" ; } 
    I just need to post an error message to the user


    Thanks in Advance...need support
  2. #2
  3. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,759
    Rep Power
    9397
    As it so happens we already have a couple threads about this exact problem. Look here

IMN logo majestic logo threadwatch logo seochat tools logo