NSDate 时间
? ? ??NSDate?*date =[NSDate?date];
?? ? ? ?
? ? ? ??NSLog(@"****%@",date);
? ? ? ??//獲取明天此時的時間以當(dāng)前時間為準(zhǔn) 時間間隔單位為 秒(以秒為時間單位計(jì)算時間間隔)
? ? ? ??NSDate?*tomorrw = [NSDate?dateWithTimeIntervalSinceNow:24*60*60];//從現(xiàn)在多少秒之后
? ? ? ??NSLog(@"tomorrw:%@",tomorrw);
? ? ? ??NSTimeInterval?tim1970 =[date?timeIntervalSince1970];//距1970多少秒
? ? ? ??NSLog(@"%f",tim1970);
? ? ? ??//格式化輸出
? ? ? ??NSDateFormatter?*dateFormater =[[NSDateFormatter?alloc]init];
? ? ? ? [dateFormater?setDateFormat:@"yyyy年MM月dd日 HH:mm:ss"];
? ? ? ??NSString?*dateString = [dateFormater?stringFromDate:date];
? ? ? ??NSLog(@"%@",dateString);
//根據(jù)秒數(shù)獲取時間
?
? ?long?long?time = [[bigDic?objectForKey:@"setoff_date"]?longLongValue];
?? ? ? ? ? ??NSDate?*confromTimesp = [NSDate?dateWithTimeIntervalSince1970:time];
? ? ? ? ? ??NSDateFormatter?*dateFormater =[[NSDateFormatter?alloc]init];
? ? ? ? ? ? [dateFormater?setDateFormat:@"yyyy-MM-dd"];
? ? ? ? ? ? ??NSString?*dateString = [dateFormater?stringFromDate:confromTimesp];
? ? ? ? ? ??
?
//獲取周幾.
?
- (NSString?*)getWeekDayFordate:(long?long)data
{
? ??NSArray?*weekday = [NSArray?arrayWithObjects: [NSNull?null],?@"周日",?@"周一",?@"周二",?@"周三",?@"周四",@"周五",?@"周六",?nil];
?? ?
? ??NSDate?*newDate = [NSDate?dateWithTimeIntervalSince1970:data];
? ??NSCalendar?*calendar = [[NSCalendar?alloc]?initWithCalendarIdentifier:NSGregorianCalendar];
? ??NSDateComponents?*components = [calendar?components:NSWeekdayCalendarUnit?fromDate:newDate];
?? ?
? ??NSString?*weekStr = [weekday?objectAtIndex:components.weekday];
? ??return?weekStr;
}
?
?
?
?
?
typedef CF_ENUM(CFIndex, CFDateFormatterStyle) { ? ?// date and time format styles
? ? kCFDateFormatterNoStyle = 0, ? ? ? // 無輸出
? ? kCFDateFormatterShortStyle = 1, ? ?// 12-10-29 下午2:52
? ? kCFDateFormatterMediumStyle = 2, ? // 2012-10-29 下午2:51:43
? ? kCFDateFormatterLongStyle = 3, ? ? // 2012年10月29日 GMT+0800下午2時51分08秒
? ? kCFDateFormatterFullStyle = 4 ? ? ?// 2012年10月29日星期一 中國標(biāo)準(zhǔn)時間下午2時46分49秒
};
?
轉(zhuǎn)載于:https://www.cnblogs.com/wukun168/p/6010818.html
總結(jié)
- 上一篇: SQL查询语句执行速度快,存储过程执行慢
- 下一篇: 最优配对问题