How to convert a unix timestamp to an ISO8601 timestamp in PHP?

mysql, php, timestamp

Solution

$timestamp = '1268932078';

$iso8601 = date('c', $timestamp);

But there are built-in functions to help you with this if you don't want to roll your own, e.g.: DateTime::diff.

Problem

I am trying to extract unix timestamp from mysql and convert it to ISO8601 timestamp. I need it in order to format date into facebook-like(or stack-overflow-like:) '30 minutes ago' instead of displaying the exact date and time. Has anyone dealt with it?

Original source