سؤال

I have date in value (long)1396267211 - How can I get NSDate from it? I think that it is a NSTimeINterval but I am not sure.

هل كانت مفيدة؟

المحلول

[NSDate dateWithTimeIntervalSince1970:[yourNumber doubleValue]]

Double value to make sure it follows NSTimeInterval precision.

نصائح أخرى

You can convert the NSInteger to NSDate as

NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:1396267211];
NSLog(@"Date is : %@",d);

Try with following code

NSDate *myDate = [NSDate dateWithTimeIntervalSince1970:1396267211];
NSLog(@"%@", myDate);

Output in console

2014-03-31 12:00:11 +0000
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top