IOS时间处理

IOS里面关于时间处理的类库有很多:

NSDate、NSCalendar、NSDateComponents、NSDateFormatter、NSTimeZone


NSDate,主要处理时间点

NSCalender,主要用于处理日历

NSDateComponents,主要用于处理日期的计算,比如把某天往前推几年几月几天等

NSDateFormatter,主要用于时间戳的处理

NSTimeZone,主要用于时区的设置


这是官方的说法:

  • NSDate allows you to represent an absolute point in time.

  • NSCalendar allows you to represent a particular calendar, such as a Gregorian or Hebrew calendar. It provides the interface for most date-based calculations and allows you to convert between NSDate objects and NSDateComponents objects.

  • NSDateComponents allows you to represent the components of a particular date, such as hour, minute, day, year, and so on.

In addition to these classes, NSTimeZone allows you to represent a geopolitical region’s time zone information. It eases the task of working across different time zones and performing calculations that may be affected by daylight savings time transitions.


具体区别,文档写的很清楚

Date and Time Programming Guide

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值