-2

I am making an app and I am fetching the feed from Twitter. The feed returns the createAt value (when a tweet was created) in this type of format:

 "Mon Jun 24 14:27:26 +0000 2013"

How can I convert it into a timestamp value like this one?

 1372070724625
Jimbo
  • 25,790
  • 15
  • 86
  • 131
  • What is "1372070724625"? – CRDave Jun 24 '13 at 14:40
  • It's a timestamp value which I get from Facebook API, but I was hoping I could be able to convert the twitter value to this one, because I have a library that converts it to "a few minutes ago", "30 minutes ago" and etc. – Vlatko Svegjan Jun 24 '13 at 14:43
  • And I dont think it's a duplicate. The other post convert the value I wrote into another type of value from the one I am aiming to achieve. – Vlatko Svegjan Jun 24 '13 at 14:45
  • What is the epoch for the timestamp? Use NSDateFormatter to convert the original string to an `NSDate`. Then use one of the `timeInterval` methods on `NSDate` to get the desired timestamp. – rmaddy Jun 24 '13 at 14:52
  • Martin below answered my question. Also I found some help on the thread http://stackoverflow.com/questions/3023264/how-to-convert-nsdate-into-unix-timestamp-in-objective-c-iphone – Vlatko Svegjan Jun 25 '13 at 07:19

1 Answers1

1

From the output of

$ TZ=GMT date -r 1372070724
Mo 24 Jun 2013 10:45:24 GMT

I would guess that 1372070724625 is the number of milliseconds since the epoch. So you should convert your string to NSDate *date using a NSDateFormatter, and then

long long timeStamp = (long long)([date timeIntervalSince1970] * 1000.0);
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382