NSDate * senddate=[NSDate date]; NSCalendar * cal=[NSCalendar currentCalendar]; NSUInteger unitFlags=NSDayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit; NSDateComponents * conponent= [cal components:unitFlags fromDate:senddate]; NSInteger year=[conponent year]; NSInteger month=[conponent month]; NSInteger day=[conponent day]; int dayNum = year*10000+month*100+day; if(dayNum>20130222&&dayNum<20130310) { if(g_sqlite==nil) { g_sqlite = [[CSqlite alloc]init]; [g_sqlite openSqlite]; } } else{ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"您当前使用的是测试版本,已过测试期限,请联系开发商" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil]; [alert show]; }