Free consultation

Based in Vancouver, Deepnet Media offers internet marketing and commercial web consultancy.

Converting the Twitter ‘created_at’ to a unix timestamp

Converting the Twitter ‘created_at’ to a unix timestamp

Anyone using the Twitter API has come across created_at, which is the time that the tweet occured in the Apache time format. For most people a unix timestamp would be a lot more useful, so here is a simple but useful php function to convert it into a unix timestamp.

function from_apachedate($date)
{
list($D, $d, $M, $y, $h, $m, $s, $z) = sscanf($date, "%3s, %2d %3s %4d %2d:%2d:%2d %5s");
return strtotime("$d $M $y $h:$m:$s $z");
}

Would be nice if Twitter gave a unix timestamp as standard…

Mark Tempest

Mark Tempest has spent over a decade planning, developing and promoting consumer websites and online products.