Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

webfuelcode's avatar

API call of timestamp in readable form

I am preparing a line chart using an API call. Here is the data:

"data": {
        "change": "0.68",
        "history": [
            {
                "price": "4523.569317441848383022",
                "timestamp": 1638424500
            },
            {
                "price": "4522.17961002978466675193",
                "timestamp": 1638424800
            },
]}

I am trying to call the timestamp in an hour and day format. (Timestamp in seconds)

0 likes
5 replies
webfuelcode's avatar

@Sinnbeck

var ctxL = document.getElementById("lineChart").getContext('2d');
var myLineChart = new Chart(ctxL, {
type: 'line',
data: {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [{
label: "My First dataset",
data: [65, 59, 80, 81, 56, 55, 40],
backgroundColor: [
'rgba(105, 0, 132, .2)',
],
borderColor: [
'rgba(200, 99, 132, .7)',
],
borderWidth: 2
},
options: {
responsive: true
}
});
martinbean's avatar

@webfuelcode APIs are for machines, not humans.

Return the timestamp as is, as it can then be easily parsed in any language, including JavaScript.

Please or to participate in this conversation.