zoukankan      html  css  js  c++  java
  • oc之获取系统当前时间的方法

    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;

    }

  • 相关阅读:
    ceph部署与问题
    openstack常见问题汇总
    css
    html
    zookeeper
    ZAB协议
    快速排序
    Servlet梳理
    tomcat性能优化梳理
    tomcat梳理
  • 原文地址:https://www.cnblogs.com/hezhuangzhuang/p/5111985.html
Copyright © 2011-2022 走看看