NSDate轉換為NSString
NSDateFormatter *date_formatter = [[[NSDateFormatter alloc]init] autorelease];
[date_formatter setDateFormat:@"YYYY/MM/dd hh:mm"];
NSString *date = [[date_formatter stringFromDate:[NSDate date]]];
NSString轉換為NSDate
NSDateFormatter *date_formatter = [[[NSDateFormatter alloc]init] autorelease];
[date_formatter setDateFormat:@"YYYY/MM/dd hh:mm"];
NSDate *date = [date_formatter dateFromString:@"2010/01/01 12:12"];
NSDateFormatter *date_formatter = [[[NSDateFormatter alloc]init] autorelease];
[date_formatter setDateFormat:@"YYYY/MM/dd hh:mm"];
NSString *date = [[date_formatter stringFromDate:[NSDate date]]];
NSString轉換為NSDate
NSDateFormatter *date_formatter = [[[NSDateFormatter alloc]init] autorelease];
[date_formatter setDateFormat:@"YYYY/MM/dd hh:mm"];
NSDate *date = [date_formatter dateFromString:@"2010/01/01 12:12"];
沒有留言:
張貼留言