如何在当前时间增加时间 [英] how to add time in current time

查看:170
本文介绍了如何在当前时间增加时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑这个。



我想抓住当前的时间,而不是根据条件,我想添加所需的时间,到当前时间。
例如。

 当前时间= 06:47:10 
//或者我应该将此格式更改为2011-03-26 06:47:10 GMT

if(a = 1和b = min)
{//添加1分钟到
当前时间
}
else if(a = 1和b = hour)
{//添加1
小时到当前时间
}
else if (a = 1和b =周)
{//添加1
周到当前时间
}

只需要将上述条件的输出添加到当前时间。



请指导我。



注意

解决方案

你现在是否像现在一样?

如果是这样,这将为您做到:

  NSDate * now = NSDate date]; //抓住当前时间
NSDate * newDate = [now addTimeInterval:XXX] //添加XXX秒到*现在

XXX是以秒为单位的时间。


I'm quite confused about this one.

I want to grab, current time, than according to condition, I want to add the required time, to the current time. for example.

current time  = 06:47:10 
//or should i hv to change this format to "2011-03-26 06:47:10  GMT"

 if(a= 1 and b= min ) 
  { //add 1 min to
  current time 
  } 
  else if(a= 1 and b= hour) 
  { //add 1
   hour to current time 
  } 
 else if(a= 1 and b=week )  
 { //add 1
 week to current time  
 }

Just need to add the output of the above condition to current time.

Please guide me with this.

Regards

解决方案

Do you mean current time, as in now?

If so, this will do it for you:

NSDate *now = [NSDate date]; // Grab current time
NSDate *newDate = [now addTimeInterval:XXX] // Add XXX seconds to *now

Where XXX is the time in seconds.

这篇关于如何在当前时间增加时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆