Re: Date time Comparison

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



http://php.net/mktime may be more suitable, depending on the date
range of the input.

That said, as far as I can tell, your $formated_expiry_date is the
SAME as your $expiry_date, except possibly for some separation
characters.

If the separation characters are ALWAYS the same, you could just do:

$current_date = date('Y/m/d H:i:s'); //match formatting of expiry date.
return $current_date < $expiry_date;


On Tue, April 18, 2006 5:02 pm, Murtaza Chang wrote:
> Hi everyone,
> this is the function I have written for comparing a date time please
> tell me
> if my logic is correct ? and if there's a better alternative please
> let me
> know of that as well.
> // This function will return 1 if supplied date is expired
> function is_expire($expiry_date){
> $current_date=date('YmdHis');
> $year=substr($expiry_date,0,4);
> $month=substr($expiry_date,5,2);
> $day=substr($expiry_date,8,2);
> $hour=substr($expiry_date,11,2);
> $min=substr($expiry_date,14,2);
> $sec=substr($expiry_date,17,2);
> $formated_expiry_date=$year.$month.$day.$hour.$min.$sec;
> if ($current_date>=$formated_expiry_date)
> return 1;
> else
> return 0;
> }
> --
> Murtaza Chang
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux