簡體   English   中英

我怎么能得到昨天的NSDate

[英]How I can get the NSDate of yesterday

我怎么能在iOS上獲得昨天的NSDate?

謝謝

這是一種方法:

NSDateComponents *components = [[[NSDateComponents alloc] init] autorelease];
[components setDay:-1];

NSDate *yesterday = [[NSCalendar currentCalendar] dateByAddingComponents:components toDate:[NSDate date] options:0];

請查看日期和時間編程指南

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM