代码下载:https://github.com/foxswang/NSDateUtil
/*MMM d, yyyy h:mm a 9月 12, 2015 7:36 下午MMM d, yyyy 9月 12, 2015MMM d h:mm a 9月 12 7:36 下午MMM d 9月 12EEEE 星期六EEEE h:mm a 星期六 7:36 下午'at' h:mm a at 7:36 下午yyyy-MM-dd 2015-09-12HH:mm:ss 19:36:24yyyy-MM-dd HH:mm:ss 2015-09-12 19:36:24 */
//yyyy-MM-dd HH:mm:ss 2015-09-12 19:36:24[date stringWithFormat:@"yyyy-MM-dd HH:mm:ss"]
类似新浪微博的 ,刚刚,1分钟前 ,1小时前,1天前,显示
[date stringWithHumanReadEasy] //输出刚刚,N分钟前,N小时前,昨天 HH:mm, YYYY-MM HH:mm
/* 获取时间的详细 */- (NSUInteger)second;- (NSUInteger)minute;- (NSUInteger)hour;- (NSUInteger)day;- (NSUInteger)weekday;- (NSUInteger)weekNumber;- (NSUInteger)month;- (NSUInteger)year;
对日期的修改,获得新的时间
//对日期的修改//增加年+ (NSDate *)dateByAddingYear:(int)year toDate:(NSDate *)date;//增加月+ (NSDate *)dateByAddingMonth:(int)month toDate:(NSDate *)date;//增加天数+ (NSDate *)dateByAddingDay:(int)day toDate:(NSDate *)date;//增加小时+ (NSDate *)dateByAddingHour:(int)hour toDate:(NSDate *)date;+ (NSDate *)dateByAddingMinute:(int)minute toDate:(NSDate *)date;+ (NSDate *)dateByAddingSecond:(int)second toDate:(NSDate *)date;
- (BOOL)isToday;- (BOOL)isYesterday;- (BOOL)isTomorrow;;
对周的一些操作
+ (BOOL)dateIsSunday:(NSDate *)date;+ (BOOL)dateIsMonday:(NSDate *)date;+ (BOOL)dateIsTuesday:(NSDate *)date;+ (BOOL)dateIsWednesday:(NSDate *)date;+ (BOOL)dateIsThurday:(NSDate *)date;+ (BOOL)dateIsFriday:(NSDate *)date;+ (BOOL)dateIsSaturday:(NSDate *)date;//本周第一天- (NSDate *)beginningOfWeek;//今天0点0分- (NSDate *)beginningOfDay;//本周的最后一天时间- (NSDate *)endOfWeek;//获取该日期所在的月的天数+ (int)numOfDaysOnMonth:(NSDate *)date;
新闻热点
疑难解答