我想獲得當前時間,但我收到了GMT。我添加了語言環境,但它沒有幫助我。我使用iPod touch。哪裏不對?我想獲得當前時間,但我收到了GMT。哪裏不對?
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
NSLocale *locale =[NSLocale currentLocale];
[dateFormatter setLocale:locale];
dateFormatter.dateFormat [email protected]"yyyy-MM-dd HH:mm:ss ZZZ";
NSDate *date = [dateFormatter dateFromString:[[NSDate date] description]];
更新:我使用NSDateFormatter,因爲我需要證明
2012-03-17 12:20:33
代替
2012-03-17 12:20:33 +0000
[NSDate的日期]給我唯一的GMT時間,但我需要一個本地時間。 – Voloda2 2012-03-17 12:18:33
是的,但是如果沒有格式化程序,您無法可靠地提取該信息。我沒有看到其界面中的任何getTimeOfDay函數。 – borrrden 2012-03-17 12:21:44