views:

47

answers:

1

Hi!

I would like to keep track of the date with timestamp. What objective-C/cocoa class could I use to get the timestamp local to the machine's time settings?

if for example I'm in USA, timestamp should be in terms of the area where I'm at. If I'm in Europe, should be in Europe time.

Small example would be so helpful!

A: 

Take a look at NSDate. For example,

NSDate *today = [NSDate date];

will give you the current date and time.

Ryan E
To expand: The NSDate class stores a timestamp as well as a timezone. If the device is an iPhone and automatically sets its time, then it will automagically save the time based on where the user is. Otherwise, it will use the system time and timezone as set by the user.
Ed Marty
No, NSDate has no concept of a timezone. It merely stores an absolute point in time. Timezones only come into play when building a description of the date for display to the user.
Mike Abdullah