Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

api

instagram

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?

like image 333
Lance Avatar asked Oct 25 '13 06:10

Lance


1 Answers

Instagram is using unix timestamp, so in your case:

echo date('M j, Y', $created_on);
like image 65
Makita Avatar answered Nov 12 '22 06:11

Makita