// 24 hour date format
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
[dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
// Now date + 12 am time fixed (00:00:00)
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSCalendarIdentifierGregorian];
NSDate *nowDate = [calendar dateBySettingHour:0 minute:0 second:0 ofDate:[NSDate date] options:0];
NSString *str = [dateFormatter stringFromDate:nowDate];
NSLog (@"String is: %@", str);
Wednesday, 13 July 2016
Update hours/minutes/seconds in NSDate | Get current date from NSDate but set custom time
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment