i like to fetch local device time and assign to string object .
NSDate* currentDate = [NSDate date];
NSDateFormatter *dateformatter=[[NSDateFormatter alloc]init];
[dateformatter setDateFormat:@"d MMMM , yyyy"];
self.dateSting=[[NSMutableString alloc]init];
self.dateSting = [NSMutableString stringWithFormat:@"%@" ,[dateformatter stringFromDate:currentDate]];
output received = 6 March , 2013
convert NSString
to NSDate
object back code below
NSDateFormatter *uu=[[NSDateFormatter alloc]init];
[uu setDateFormat:@"d MMMM , yyyy"];
NSDate *yy=[uu dateFromString:self.dateSting];
output recived=2013-03-05 18:30:00 +0000
difference coming in days.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…