我是靠谱客的博主 纯情芹菜,最近开发中收集的这篇文章主要介绍iOS 获得现在的时间代码,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

一, 代码。

- (void)viewDidLoad {
  [super viewDidLoad];
  // Do any additional setup after loading the view, typically from a nib.
  
  //获得现在的时间
  [self currentTime];
}
#pragma -mark -functions
//计算现在的时间
- (void)currentTime
{
  //时间格式
  NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  //现在时间
  NSDate * currentdate = [NSDate date];
  NSString * currentDateString = [dateFormatter stringFromDate: currentdate];
  NSLog(@"---currentDateString--%@",currentDateString);
}

二,输出。

2015-10-23 10:15:24.928 计算现在的时间[1607:61610] ---currentDateString--2015-10-23 10:15:24

以上所述是小编给大家介绍的iOS 获得现在的时间代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对靠谱客网站的支持!

最后

以上就是纯情芹菜为你收集整理的iOS 获得现在的时间代码的全部内容,希望文章能够帮你解决iOS 获得现在的时间代码所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(97)

评论列表共有 0 条评论

立即
投稿
返回
顶部