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