Markcce Eros Markcce Eros - 16 days ago 5
Javascript Question

Javascript convert unix date to ddmmyy format

I have a chart that's giving me this date:

1577612800000


I need to convert it to "ddmmyy" format

I found this:

var timestamp = 1577612800000;
var date = new Date(timestamp * 1000);


But it has no format.

How can I do this with format ddmmyy ?

Answer

Get values from Date object and generate the string by concatenation.

var timestamp = 1577612800000;
var date = new Date(timestamp);
console.log(
  date.getDate() + '' + (date.getMonth()+1) + date.getFullYear()
)

Comments