0
data.date = new Date(jObjectTip.getLong("createdAt") * 1000);

That command is used to grab data from FourSquare.

Anonymous White
  • 2,149
  • 3
  • 20
  • 27

2 Answers2

1

Uh...not sure what the "createAt" * 1000 means. 1000 times the current date and time?

In Objective C you can use:

  • (id)initWithTimeIntervalSinceNow:(NSTimeInterval)seconds

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html

to create a date time object with an offset:

// creates a date time that is 1000 seconds away from the current time
NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:1000];
Zhang
  • 11,549
  • 7
  • 57
  • 87
1

Assuming that createdAt is unix timestamp, the code will be:

NSTimeInterval createdAt = ...;
NSDate *resultDate = [NSDate dateWithTimeIntervalSince1970:createdAt];

Note that NSTimeInterval is a typedef for double, and it stores the time in seconds, unlike Java, so there's no need to multiply the value by 1000;

Andrey Zverev
  • 4,409
  • 1
  • 28
  • 34