B
B
Be Clack2018-09-12 14:09:14
JavaScript
Be Clack, 2018-09-12 14:09:14

How to get only time with Last FM API?

Hello, help me get the correct time from
https://ws.audioscrobbler.com/2.0/?method=user.get...
I take this:

<script>
// last.fm user get recent tracks
// docs: https://www.last.fm/api/show/user.getRecentTracks

$.getJSON("https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=tumarfm&api_key=0a1d291e241f00167608af030298c212&format=json", function (data) {
    $.each(data["recenttracks"]["track"], function (key, value) {
        var song = value["name"];
        var artist = value["artist"]["#text"];
        var date = value["date"]["#text"];

        var html = "<li>";
        html += "<a href=\"#\"></span>";
    		html += "<b>" + song + "</b>";
    		html += "<br/>" + artist + "</a>";
        html += "</li>";
        
        $("#results").append(html);
    });
})
// Errors are your friend!.. Use them..
.error(function (jqXHR, textStatus, errorThrown) {
    console.log("error " + textStatus);
    console.log("error throw " + errorThrown);
    console.log("incoming Text " + jqXHR.responseText);
}) // End of .error
.complete(function () {
    console.log("complete");
});
</script>

As a result, I get the date format - "2 Sep 2018, 10:48"
How to get only the time? + in another time zone ? for example, the time zone is +6
or even better, how to turn this date into the form "3 minutes ago" for example

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Shekhovtsov, 2018-09-12
@Ksedline

Try using momentjs.com for this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question