int main(int argc, const char * argv[]) {

 

    @autoreleasepool {

 

        

 

        NSDate* date = [NSDate date];

 

        NSLog(@"%@",date);

 

        NSLog(@"%@",[date descriptionWithLocale:[NSLocale currentLocale]]);

 

        

 

        //NSDate和NSString转换

 

        NSDateFormatter* formattor = [[NSDateFormatter alloc]init];

 

        formattor.dateFormat=@"yyyy-MM-dd hh:mm:ss";

 

        NSString* str = [formattor stringFromDate:date];

 

        NSLog(@"%@",str);

 

        //获取年月日

 

        NSCalendarDate* calender = [NSCalendarDate calendarDate];

 

        NSInteger year = [calender yearOfCommonEra];

 

        NSLog(@"%ld",year);

 

      

 

        

 

    }

 

    return 0;

 

}

 

 

 

相关文章:

  • 2021-06-29
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-01-02
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
相关资源
相似解决方案