how can i display current time on a label iphone?
Objective-C
NSDate *currDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"dd.MM.YY HH:mm:ss"];
NSString *dateString = [dateFormatter stringFromDate:currDate];
yourLabel.text=dateString
Swift 3.0
var currDate = Date()
var dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd.MM.YY HH:mm:ss"
var dateString = dateFormatter.string(fromDate: currDate)
yourLabel.text! = dateString
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With