0

How do I compare the timestamp "createdAt" (2015-09-07T10:02:50.868Z) between the current time and get: 1h ago, or 5h ago etc?

Since Parse saves the time in GMT, what happens if the user is in a different time zone? How do I successfully solve this problem?

1 Answers1

0

You can create Date From String using GMT Timezone and then compare [NSDate date] and converted date. You can use NSDateComponents and NSCalendarUnit. refer this How to convert NSDate in to relative format as "Today","Yesterday","a week ago","a month ago","a year ago"?

You can also use this its a good library. https://github.com/kevinlawler/NSDate-TimeAgo

Hope this will help. but first you should convert string to date using GMT timezone then only you can compare both GMT dates. One is your current global time and second is your server global time. so it will give you same difference in any timezone. Hope you understand.

Community
  • 1
  • 1
ChintaN -Maddy- Ramani
  • 5,156
  • 1
  • 27
  • 48
  • Worked perfectly, thank you. I ended up using: https://github.com/MatthewYork/DateTools –  Sep 08 '15 at 05:24