IOS基本类方法与实例方法之日期总结

method of class


+ data 
return value:A new object set to the current date and time (创建一个新的日期对象实例)


+ (instancetype) dateWithTimeIntervalSinceNow:(NSTimeInTerval)seconds
Function:creates and return an NSDate object set to a give number of seconds from the current date and time
retutn value:An NSDate objecet set to seconds from the current date and time(创建一个现在时间和日期的实例)


+ (instancetype)dateWithTimeInterval:(NSTimeInterval)seconds
                                       sinceDate:(NSDate *)date
Function:Creates and returns an NSDate object set to a given number of seconds from the specified date.
(创建一个距离sincedate有seconds的日期实例)


+ (instancetype)dateWithTimeIntervalSinceReferenceDate:(NSTimeInterval)seconds
Function:Creates and returns an NSDate object set to a given number of seconds from 00:00:00 UTC on 1 January 2001.
(创建一个距离2001年1月1日00:00:00日期有Seconds的日期实例)


+ (instancetype)dateWithTimeIntervalSince1970:(NSTimeInterval)seconds
Function:Creates and returns an NSDate object set to the given number of seconds from 00:00:00 UTC on 1 January 1970.
(创建一个距离1970年1月1日00:00:00有Seconds的日期实例)


+ (NSDate *)distantFuture
Function:Creates and returns an NSDate object representing a date in the distant future.
(返回一个距离现在很久的将来日期类实例)


+ (NSDate *)distantPast
Function:Creates and returns an NSDate object representing a date in the distant past.
(返回一个距离现在很久的过去日期类实例)


+ (NSTimeInterval)timeIntervalSinceReferenceDate
Function:Returns an NSDate object initialized relative to the current date and time by a given number of seconds.
Function:Returns the interval between 00:00:00 UTC on 1 January 2001 and the current date and time.
(返回一个现在距离2001年的时间)


instance of class
- (instancetype)initWithTimeIntervalSinceNow:(NSTimeInterval)seconds
Function:Returns an NSDate object initialized relative to the current date and time by a given number of seconds.
(初始化一个距离现在有Seconds的实例)


- (instancetype)initWithTimeInterval:(NSTimeInterval)seconds
                                     sinceDate:(NSDate *)refDate
Function:Returns an NSDate object initialized relative to another given date by a given number of seconds.
(初始化一个距离日期实例refDateyou有seconds的实例)


- (instancetype)initWithTimeIntervalSinceReferenceDate:(NSTimeInterval)seconds
Function:Returns an NSDate object initialized relative to 00:00:00 UTC on 1 January 2001 by a given number of seconds.
(初始化一个距离2001年有Seconds的实例)


- (instancetype)initWithTimeIntervalSince1970:(NSTimeInterval)seconds
Function:Returns an NSDate object initialized relative to 00:00:00 UTC on 1 January 1970 by a given number of seconds.
(初始化一个距离1970年有Seconds的实例)


Comparing Date


- (BOOL)isEqualToDate:(NSDate *)anotherDate
Function:Returns a Boolean value that indicates whether a given object is an NSDate object and exactly equal the receiver.
(返回一个数值:与另一个日期对象相比较是否相等)


- (NSDate *)earlierDate:(NSDate *)anotherDate
Function:Returns the earlier of the receiver and another given date.
(两个日期对象相比 返回更早日期的那个日期对象)


- (NSDate *)laterDate:(NSDate *)anotherDate
Function:Returns the later of the receiver and another given date.
(两个日期对象相比 返回更晚日期的那个对象)


- (NSComparisonResult)compare:(NSDate *)anotherDate
Function:Returns an NSComparisonResult value that indicates the temporal ordering of the receiver and another given date.
(两个对象相等:返回0 目标对象比参数(another)晚:返回1 | 目标对象比参数(another)早:返回-1)


Geting Timer Intervals


- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate
Function:Returns the interval between the receiver and another given date.
(返回一个在目标和参数间的时间值(seconds))



Add A Time Interval


- (instancetype)dateByAddingTimeInterval:(NSTimeInterval)seconds
Function:Returns a new NSDate object that is set to a given number of seconds relative to the receiver.
(返回一个日期对象:距离目标有Seconds)


description
- (NSString *)descriptionWithLocale:(id)locale
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值