Lance
Lance

Reputation: 4820

Turning Instagram's "created_time" key into an actual date

I'm using Instagram's API to fetch a given profile's most recent video or photo that was posted. It's working well, except that I can't seem to make sense of what the "created_time" value means.

$feed = file_get_contents("https://api.instagram.com/v1/users/".$id."/media/recent/?access_token=".$access_token."&count=1");
$feed = @json_decode($feed, true);
$created_on = $feed['data'][0]['created_time'];

The $created_on variable in this case is set to 1382576494. When I try to do,

echo date('M j, Y', strtotime($created_on));

I get an error message. What sort of format is Instagram using?

Upvotes: 10

Views: 16962

Answers (1)

Makita
Makita

Reputation: 1812

Instagram is using unix timestamp, so in your case:

echo date('M j, Y', $created_on);

Upvotes: 19

Related Questions