[ciapug] Dates question

Lathrop Preston ciapug@cialug.org
Fri, 17 Sep 2004 19:23:43 -0500


> This is some date code from gforge:
> 
> $date_list = split('[- :]',$release_date,5);
> $release_date = 
> mktime($date_list[3],$date_list[4],0,$date_list[1],$date_list[2],$date_list[0]); 
> 
> 
> This rips a date like "2004-09-17 16:43" and makes it into unix time 
> (seconds since 1970).
> 
> You should be able to apply that logic to both of your dates and then test
> 
> if (($date2-$date1) > (30*24*60*60)) {
>     greater than 30 days
> }
> 

If $date1 and $date2 are in a standard format you can get the unix time 
directly with strtotime($date) instead of needing to do the split and mktime

ie

if( (strtotime($date2) - strtotime($date1)) > (30*24*60*60)){
	greater than 30 days
}else{....

Laith