私はすべてを読みましたが、私の問題を解決するものは何もNSDate
ありません。NSDateFormatter
現在の日付を取得し、NSDateオブジェクトでこの日付をモントする必要がありますが、これを行うと、私の時間は常に+2時間になります。私はそのようなことをしています:
NSDateFormatter * dateformatter = [[NSDateFormatter alloc]init];
[dateformatter setLocale:[NSLocale currentLocale]];
[dateformatter setDateFormat:@"yyyy-mm-dd HH:mm:ss"];
//NSTimeZone* localTimeZone = [NSTimeZone localTimeZone];
//NSLog(@"timezone local = %@",localTimeZone);
//[NSTimeZone timeZoneWithAbbreviation:@"BRST"];
NSString * current = [dateformatter stringFromDate:[NSDate date]];
NSLog(@"current = %@",current); // Cool this is my current date!
NSDate *thedate = [dateformatter dateFromString:current];
NSLog(@"date = %@",thedate);// NO! my hours is wrong
現在の日付をに追加する必要があります。また、文字列を使用して(メソッドを使用して)NSDate
を追加する必要があります。文字列の例:2013-01-2117:05:17。NSDateを返すメソッドでこの文字列を渡すと、NSDateを出力し、この間違った日付を取得します:2013-01-2119:05:17+0000。NSDate
stringFromDate
stringFromDate
ただの履歴書:
NSDateに現在の日付を追加する必要があり、 2013-01-2117:05:17
NSDate
のように追加する必要もあります。NSString
私の現在のローカルはブラジル/サンパウロで、NSTimerZoneの略語はBRSTです。