Convert NSString of a date to an NSDate

后端 未结 3 1194
离开以前
离开以前 2020-12-01 21:23

This might be a silly question, but I can\'t seem to find the answer on here or in the documentation.

I want to convert an NSString such as @\"9/22/2010 3:45 PM\" t

3条回答
  •  一生所求
    2020-12-01 22:17

    You can parse an NSString into an NSDate using the NSDateFormatter class. See the documentation for more info:

    Instances of NSDateFormatter create string representations of NSDate (and NSCalendarDate) objects, and convert textual representations of dates and times into NSDate objects.

提交回复
热议问题