swift nsdate add seconds
ios – How to add minutes to current time in swift – Stack Overflow
iphone – How do i add 1 day to a NSDate? – Stack Overflow
ios – SWIFT: How do I add hours to NSDate object – Stack Overflow
let earliestMsgDate = NSDate() print("earliestMsgDate=\(earliestMsgDate)") let curCalendar:NSCalendar = NSCalendar.currentCalendar() print("curCalendar=\(curCalendar)") let prevDayOfEarliestMsgDate:NSDate = curCalendar.dateByAddingUnit(NSCalendarUnit.Day, value: –1, toDate: earliestMsgDate, options: [])! print("prevDayOfEarliestMsgDate=\(prevDayOfEarliestMsgDate)") |
效果:
earliestMsgDate=2015-12-13 04:48:48 +0000 curCalendar=<_NSCopyOnWriteCalendarWrapper: 0x7f955b434c30> prevDayOfEarliestMsgDate=2015-12-12 04:48:48 +0000 |
如图:
转载请注明:在路上 » [已解决]Swift中给当前NSDate增加一天