Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Properly displaying Instagram date

This is a dirty JSFiddle version of my web app, however, I do not understand how to properly adjust the date from the Unix TimeStamp, all I want to display is the month, day, and year.

Any help would be greatly appreciated it!

http://jsfiddle.net/89YCe/

Here is the Code:

    $(function() {
    $.ajax({
        type: "GET",
        dataType: "jsonp",
        cache: false,
        url: "https://api.instagram.com/v1/tags/crookedspaces/media/recent/?access_token=16741082.1b07669.121a338d0cbe4ff6a5e04543158a4f82",
        success: function(data) {
            console.log(data);
            //OKAY, now lets get to the pretty stuff, INSTAGRAM PEEKTARS.
            for (var i = 0; i < 5; i++) {
                    $(".instagram").append("\
                        <div class='instagram-feed'>\
                            <img class='instagram-image' src='" + data.data[i].images.standard_resolution.url +"' width='325px'/>\
                            <div class='igHover2'>\
                                posted by: "+data.data[i].user.username+"<br />\
                                posted on: "+Date(data.data[i].created_time).toString()+"<br />\
                            </div />\
                        </div>\
                    ");
            }
        }
    });
});​
like image 322
tbremer Avatar asked Sep 26 '12 23:09

tbremer


1 Answers

Here you are:

$(function() {
    $.ajax({
        type: "GET",
        dataType: "jsonp",
        cache: false,
        url: "https://api.instagram.com/v1/tags/crookedspaces/media/recent/?access_token=16741082.1b07669.121a338d0cbe4ff6a5e04543158a4f82",
        success: function(data) {
            console.log(data);
            //OKAY, now lets get to the pretty stuff, INSTAGRAM PEEKTARS.
            for (var i = 0; i < 5; i++) {
                var date = new Date(parseInt(data.data[i].created_time) * 1000);
                    $(".instagram").append("\
                        <div class='instagram-feed'>\
                            <img class='instagram-image' src='" + data.data[i].images.standard_resolution.url +"' width='325px'/>\
                            <div class='igHover2'>\
                                posted by: "+data.data[i].user.username+"<br />\
                                posted on: "+(date.getMonth()+1)+"/"+date.getDate()+"/"+date.getFullYear()+"<br />\
                            </div />\
                        </div>\
                    ");
                date = null;
            }
        }
    });
});

And a live demo with this working http://jsfiddle.net/89YCe/2/

like image 95
Igor Shastin Avatar answered Sep 20 '22 19:09

Igor Shastin