Calculate time difference in Cocoa

后端 未结 4 855
逝去的感伤
逝去的感伤 2021-02-04 08:53

I have got two timevalues in the format: %H%M%S (E.G.161500)

These values are text-based integers.

Is there a simple function in Cocoa that calculates the diffe

4条回答
  •  再見小時候
    2021-02-04 09:42

    The class for manipulating dates is NSDate. The method for getting time intervals is -timeIntervalSinceDate:. The result is a NSTimeInterval value, which is a double representing the interval in seconds.

    You can create a NSDate object from a NSString with +dateWithString:, provided that your date is formatted as 2001-03-24 10:45:32 +0600.

提交回复
热议问题