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

来源:互联网 发布:智阳网络有年终奖吗 编辑:程序博客网 时间:2024/05/29 19:32
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