How do I get hour and minutes from NSDate?

后端 未结 8 1397
清歌不尽
清歌不尽 2020-12-02 05:26

In my application I need to get the hour and minute separately:

NSString *currentHour=[string1 substringWithRange: NSMakeRange(0,2)];
        int currentHour         


        
8条回答
  •  盖世英雄少女心
    2020-12-02 06:08

    NSDateComponents

    All you need can be found here:
    https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/DatesAndTimes/Articles/dtCalendars.html

提交回复
热议问题