Skip to content

Instantly share code, notes, and snippets.

@katsuhide
Created May 31, 2013 15:14
Show Gist options
  • Save katsuhide/5685660 to your computer and use it in GitHub Desktop.
Save katsuhide/5685660 to your computer and use it in GitHub Desktop.
ローカル時刻を取得するようにNSDateを拡張
@interface NSDate (Util)
- (NSDate*)toLocalTime;
@end
#import "NSDate+Util.h"
@implementation NSDate (Util)
- (NSDate*)toLocalTime{
NSTimeZone *tz = [NSTimeZone defaultTimeZone];
NSInteger seconds = [tz secondsFromGMTForDate: self];
return [NSDate dateWithTimeInterval: seconds sinceDate: self];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment