//
+(NSDictionary *)getTimeFromDate:(NSDate *)date
{
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSLocale *zhLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
[calendar setLocale:zhLocale];
NSDateComponents *comps = [[NSDateComponents alloc] init];
NSInteger unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitWeekday |
NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
comps = [calendar components:unitFlags fromDate:date];
NSDictionary *result = @{
@"year":[NSNumber numberWithInt:[comps year]],
@"month":[NSNumber numberWithInt:[comps month]],
@"day":[NSNumber numberWithInt:[comps day]],
@"hour":[NSNumb
ios 获取日期(年、月、日、星期、时、分、秒)
最新推荐文章于 2023-02-13 14:54:40 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)