Retrieving current local time on iPhone?

后端 未结 7 648
我寻月下人不归
我寻月下人不归 2020-12-01 07:57

I\'m looking to get the current hour and minute on a user\'s iPhone for display in an app that doesn\'t show the status bar. Is there a simple way to do this?

7条回答
  •  渐次进展
    2020-12-01 08:11

    A shorter approach

    NSDate * now = [NSDate date];
    timeLabel.text = [NSDateFormatter localizedStringFromDate:now
                                                    dateStyle:NSDateFormatterNoStyle
                                                    timeStyle:NSDateFormatterShortStyle];
    

提交回复
热议问题