1

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.

user3473938
  • 25
  • 1
  • 5
  • 2
    You should start by being sure what the number means. Does it mean `03 / 31 / 14 @ 12:00:11pm UTC` ? – Wain Mar 31 '14 at 12:25
  • just put NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:1396267211]; and you will get your ans – Bhanu Mar 31 '14 at 12:30

3 Answers3

7
[NSDate dateWithTimeIntervalSince1970:[yourNumber doubleValue]]

Double value to make sure it follows NSTimeInterval precision.

Grzegorz Krukowski
  • 18,081
  • 5
  • 50
  • 71
1

You can convert the NSInteger to NSDate as

NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:1396267211];
NSLog(@"Date is : %@",d);
Himanshu Joshi
  • 3,391
  • 1
  • 19
  • 32
0

Try with following code

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

Output in console

2014-03-31 12:00:11 +0000
iPatel
  • 46,010
  • 16
  • 115
  • 137