Code for formatting dates in Objective-C and Ruby to conform to the Twitter "Developer Display Requirements"
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Tweet Date Format

Twitter's Developer Display Requirements dictate the required format that tweets are displayed in 3rd party apps and websites.

One part of this requirement is to format the Tweet Timestamp consistent with their guidelines. The code here includes an Objective-C category for NSDate and a Rails helper method for doing the formatting.

The output for the tweet dates will be something like:

# less than a minute

# less than an hour

# less than 24 hours

# for older than 24 hours
"9 May"

# for older than a year
"5 Dec 12"


Objective-C category usage:

[[NSDate date] tweetDistanceOfTime:tweetedAt];

Ruby helper method:

<%= tweet_distance_of_time(tweeted_at) %>

Javascript function:

$> npm install
tweetDate = require("./tweet_date");
var formatted = tweetDate.tweetDistanceOfTime("2013-05-06 12:30:00");


Copyright (c) 2013 Derek DeVries

Released under the MIT License