type casting to float to "ensure reliable comparison" ?

From: maxim vexler ("maxim)
Date: 08/07/04


Date: Sat, 07 Aug 2004 20:17:22 +0000

in a book i am ready now : O'Reilly - Web Database Application with PHP
and MySQL, 2nd ed. by David Lane, Hugh E. Williams

on chapter 9 the author give an example for age validation :
(simplified code, not a direct quote)

$dob = mktime(0,0,0, 5, 3, 1983);

if ((float)$dob > (float)strtotime("-18years"))
{
        print "....";
        return false;
}

my question is why the type casting to float ?
after all the return type of both mktime & strtotime is int, why the
need to cast to float?
the authors emphasize this in the explanation section by "We use the
mktime() function to convert the date of birth to a large numeric Unix
timestamp value, and the strtotime() function to discover the timestamp
of exactly 18 ago. *Both are cast to a large floating number to ensure
reliable comparison...*"

thank you for comment's ohh & yes - hope I'm not breaking any copyright
lows :).



Relevant Pages

  • Re: SQL timestamp column for concurrency
    ... In your SQL Stored Procedures cast the timestamp to an int type during ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Passing Timestamp value to sql server
    ... the following example cast the timestamp to a data type of datetime: ... You can also cast it to another type. ... >I still need to pass the value back to the server. ...
    (microsoft.public.access.adp.sqlserver)
  • Re: bad usage of strtotime?
    ... Suppose I need to know if date1 is smaller/equal or bigger than date2. ... date format and will try to parse that format into a Unix timestamp ... Since the strtotime() is calculating 2 times the Unix ... any case be a standard Unix timestamp, which is the number of seconds ...
    (comp.lang.php)
  • Re: [PHP] Previous and Next Month and Year
    ... I generally use strtotime() as the swiss army knife of PHP date handling. ... new timestamp. ... exclusive property, it is the action of the thinking power called an idea, ... which an individual may exclusively possess as long as he keeps it to ...
    (php.general)
  • Re: type casting to float to "ensure reliable comparison" ?
    ... > (simplified code, not a direct quote) ... > mktime() function to convert the date of birth to a large numeric Unix ... > timestamp value, and the strtotimefunction to discover the timestamp ...
    (comp.lang.php)