Perhaps this will be more readable:
NSDateFormatter *date = [[NSDateFormatter alloc] init]; [date setDateFormat:@"HH:mm"]; NSString *dateString = [date stringFromDate:[NSDate date]]; [self.time setText:dateString];
First of all, we create the built-in obj-c NSDateFormatter named date , then apply it using [[NSDateFormatter alloc] init]; . After that, we tell the code process that we want our date to have HOUR / MINUTE / SECOND. Finally, we must make our date a string to work with a warning or set the label value, for this we must create a string with the NSString method, then we will use this: [date stringFromDate: [NSDate date]]
Have some fun with it.
AmirHossein Jun 04 2018-12-14T00: 00Z
source share