Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
If you want to use Cocoa you can call
Code:
[[NSDate date] timeSince1970]
for the Unix epoch (00:00:00 GMT, 01/01/1970) or
Code:
[[NSDate date] timeSinceReferenceDate]
for the Mac OS X epoch (00:00:00 GMT, 01/01/2001). Both of these return an NSTimeInterval type (which is really just a typedef'd double and measured in seconds).
 
Do not use epoch time. It will be completely broken in 2038.

I'm kidding. :) I mean, it WILL be broken in 2038, but obviously that's 29 years from now.
 
Do not use epoch time. It will be completely broken in 2038.

I'm kidding. :) I mean, it WILL be broken in 2038, but obviously that's 29 years from now.

Not really. Most operating systems that use epoch time are moving to a 64-bit wide time_t instead of a 32-bit one so it's really a non-issue. You may want to then want to worry about the 64 bit value overflowing but I'm relatively sure you should be more concerned with the sun burning out. This is a non-issue when using the Cocoa API as it uses a double to represent the time.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.