Hi all,
How can you convert the UNIX timestamp (that is in the form of a number denoting timestamp) into date, time(hours, minutes, seconds) in Objective-C?
Thanx in advance.
Hi all,
How can you convert the UNIX timestamp (that is in the form of a number denoting timestamp) into date, time(hours, minutes, seconds) in Objective-C?
Thanx in advance.
For output, use an NSDateFormatter
. To extract values for other purposes, use NSDateComponents
. eg:
NSDate *date = [NSDate dateWithTimeIntervalSince1970:1234567];
NSDateComponents *weekdayComponents = [[NSCalendar currentCalendar] components:NSWeekdayCalendarUnit fromDate:date];
int weekday = [weekdayComponents weekday];