relative-date
How to convert NSDate in to relative format as “Today”,”Yesterday”,”a week ago”,”a month ago”,”a year ago”?
For simplicity I’m assuming that the dates you are formatting are all in the past (no “tomorrow” or “next week”). It’s not that it can’t be done but it would be more cases to deal with and more strings to return. You can use components:fromDate:toDate:options: with whatever combination of date components you are looking for … Read more
Javascript timestamp to relative time
Well it’s pretty easy if you aren’t overly concerned with accuracy. What wrong with the trivial method? function timeDifference(current, previous) { var msPerMinute = 60 * 1000; var msPerHour = msPerMinute * 60; var msPerDay = msPerHour * 24; var msPerMonth = msPerDay * 30; var msPerYear = msPerDay * 365; var elapsed = current … Read more