博客> iOS-获取当前时间
iOS-获取当前时间
2小时前 评论:0 阅读:827 OS_JJ
ios 获取当前时间
         NSDate *currentDate = [NSDate date];//获取当前时间,日期
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"YYYY-MM-dd"];
        NSString *dateString = [dateFormatter stringFromDate:currentDate];
        NSLog(@"dateString:%@",dateString);

        UILabel *timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 110 + self.picWhith + 30, WIDTH, 20)];
        timeLabel.text = dateString;
        timeLabel.textAlignment = NSTextAlignmentCenter;
        timeLabel.font = [UIFont systemFontOfSize:16];
        timeLabel.textColor = WHITECOLOR;
        [self.view addSubview:timeLabel];
收藏
0
sina weixin mail 回到顶部