Hi Sundog, Can help you with dates (but no, if you want that kind you'll definitely not be wanting my advice...)
----- Original Message ----- > I am trying to determine if todays date ($today) is within a week > ($startcheck) of a given date ($dob). This is what I have so far. > > $todaydate = (date("Y-d-m")); > $today = strtotime($todaydate); > // $today prior to strtotime = 2001-10-11 > $startcheck = strtotime(2001-08-11); > $dob = strtotime(2001-15-11); > > //$today is CLEARLY between the two dates I'm testing with but "no" is > always returned. > > if($today <= $dob && $startcheck <= $today) { > print "yes"; > } > else { > print "no"; > } > > Here are the values assigned to the vars, why is $today so much smaller > than $startcheck and $dob? > > 1002783600 = today > 1005452940 = startcheck > 1005451980 = dob > > win32 php4 Let's start with "perceptions" because there's a couple here that have the potential to hold you on the side-benches whilst everyone else has a date and has made it to the dance floor... The manual (http://www.php.net/manual/en/function.strtotime.php) says, "strtotime -- Parse about any english [sic] textual datetime description into a UNIX timestamp". The key word is "any" and the fact that it is not "all". > //$today is CLEARLY between the two dates I'm testing with but "no" is > always returned. Er, no - it is not "clear"! A quick geography/horology lesson: the rest of the world either do not use the same date system or do not express the Gregorian calendar the way Americans do. Today no one has a problem with a date written as 11/11/2001, but when 10/11/2001 is written down, does it mean yesterday (10-Nov-2001) or one month back (11-Oct-2001)? In America, the two formats are known as "American" (MM/DD/CCYY) and "European" (DD/MM/CCYY) format. Moving to the format used in the code above (20011111). A format of this nature is widely used because it facilitates sorting/comparisons - ah but watch those perceptions, if you were comparing/sorting/performing arithmetic on two dates, one in Oct and one in Nov, then the convention will have to be CCYYMMDD = century, year, month, then day! BTW you will see the logical flow of this ever decreasing period/increasing precision, and how it can be kept going into CCYYMMDDHHMMSS and thereafter depending upon your needs, time base/available utility functions, etc! The function is called 'string to time'. In other words, a series of alphanumeric characters are passed, and a date-time is returned (in the form of a UNIX timestamp). Given that there are many perceptions involved in interpreting what the incoming string of digits means, some dates cannot be unambiguously expressed/resolved (eg yesterday's date). It's always a good idea to add some 'debug echoes' to new code, just to be sure that your perceptions agree with the computer's implacable logic - I added to your code: echo "Todaydate=$todaydate~"; echo "<br>Today=$today~ Startcheck=$startcheck~ DoB=$dob~"; echo "<br>". "Today=".date("Y-M-d",$today). "~ Startcheck=".date("Y-M-d",$startcheck). "~ DoB=".date("Y-M-d",$dob)."~"; and this was returned: Todaydate=2001-11-11~ Today=1005436800~ Startcheck=1005510600~ DoB=1005509700~ Today=2001-Nov-11~ Startcheck=2001-Nov-11~ DoB=2001-Nov-11~no The last "no" is the original output, but before that you can see 'why' - if the date values/definitions are modified, the code works exactly as (I perceive, is) required. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]