I'm actually working with fbconnect and I'm trying to get a unix time that represents a month ago. I'm really confused about this since 1970 thing. Cause some body give me a point in the right direction?
With the Unix epoch, time "0" is midnight on January 1st, 1970. Every second since, another second has been added; the time right now as I write this is:
>>> import time
>>> time.time()
1257023557.94208
Most systems communicate using the Unix epoch because it is easy, de-facto standard, and allows integer arithmetic. You can get an NSTimeInterval
representing the duration since the epoch from an NSDate
like this:
NSTimeInterval timestamp = [[NSDate date] timeIntervalSince1970];
An NSTimeInterval is just a double. If you want an integer -- which I imagine fbconnect needs -- just convert it (untested):
NSString *strtimestamp = [NSString stringWithFormat:"%u", [timestamp unsignedIntegerValue]];
Remember, it's just a count. You can subtract an hour by subtracting 3600 (60 * 60), add a day by adding 86400 (24 * 60 * 60), and so forth; however, it's better in your case to start with an NSDate representing the specific time you want and allowing the library to do the arithmetic for you.
NSDate
is probably just a wrapper around these timestamps.