The way you want to do this is with UNIX timestamps. FYI a timestamp is the
number of seconds starting at 1970 and going up (it's important to remember 
that date - since some people were born before, etc.)

So you need to do this:
  
  $dateA = '12-25-1999';
  $dateB = '12-24-1999';
  
  // convert to unix time stamps
  $fooA = explode('-',$dateA);
  $fooB = explode('-',$dateB);
  
  $timestampA = mktime(0,0,0,$fooA[0],$fooA[1],$fooA[0]);
  $timestampB = mktime(0,0,0,$fooB[0],$fooB[1],$fooB[0]);
  
  if($timestampA > $timestampB)
  {
    echo $dateA . " is greater than B"; 
  }

Hope this helps - you can also check out this page:

http://www.php.net/manual/en/ref.datetime.php

--Joe


On Mon, Jan 15, 2001 at 12:00:05PM -0600, Jacky@lilst wrote:
> Greeting all,
> Just now I asked about to tie string values together and would like to thank
> Jason for that. Anyway one more thing, after I have tied string values
> together and assigned that to a virables. can I used the value from that
> variables to compare with another date value? Say another date value I will
> use is also retrieved from a field in table which is in Date data type as
> well. So it will be like
> 
> 
> $query = "select myBirthdate from date where userId='1' ";
> $dateResult =mysql_query($query);
> $myBirthDate = (mysql_result($dateResult,0,"myBirthdate"));
> 
> $thisBirthdate = "$year"."$month"."$day";
> 
> if ($thisBirthdate < $myBirthdate) {
> do something
> } else {
>  do some other thing
> }
> 
> Is it the correct way to do that?
> cheers
> Jack
> [EMAIL PROTECTED]
> "There is nothing more rewarding than reaching the goal you set for
> yourself"
> 
> 
> -- 
> 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]

-- 

Joe Stump, PHP Hacker
[EMAIL PROTECTED]
http://www.miester.org/


-- 
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]

Reply via email to