Get UTC time and local time from NSDate object

前端 未结 10 1006
夕颜
夕颜 2020-11-28 23:17

In objective-c, the following code results in the UTC date time information using the date API.

NSDate *currentUTCDate = [NSDate date]
         


        
10条回答
  •  迷失自我
    2020-11-28 23:41

    At the moment (with the latest changes to Swift), NSDate.date() is not longer available.

    Instead you just need to initialize NSDate and it gets the current date and time.
    To try it, in a playground:

    var d = NSDate()
    d
    

    and you will get:

    Oct 22, 2014, 12:20 PM"  
    

提交回复
热议问题