当前位置: 移动技术网 > IT编程>移动开发>IOS > iOS 获得现在的时间代码

iOS 获得现在的时间代码

2019年07月24日  | 移动技术网IT编程  | 我要评论

魔兽世界南音梦予,天地姻缘琉璃仙女,东莞废金属回收

一, 代码。

- (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 获得现在的时间代码,希望对大家有所帮助

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网