1

I have this date format:

"Mon Jun 5 00:00:00 UTC-04:00 2017"

How can I convert it to any human-readable format?

Michael
  • 13,950
  • 57
  • 145
  • 288

2 Answers2

2

Depending on what format you want you can use the JavaScript Date object. Documentation of other methods found here.

let date = new Date("Mon Jun 5 00:00:00 UTC-04:00 2017");
console.log(date.toString());
console.log(date.toDateString());
console.log(date.toLocaleString());
console.log(date.toLocaleDateString());
console.log(date.toUTCString());
Matt Davis
  • 1,167
  • 8
  • 21
-1

I hope this helps

var str = "Mon Jun 5 00:00:00 UTC-04:00 2017";

var date = new Date(str);
console.log(date);

var year = date.getFullYear();
var month = date.getMonth();
var day = date.getDate();
var hour = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();

var output = `Year: ${year}/${month}/${year}  Time: ${hour}:${minutes}:${seconds}`;

console.log(output);
sonEtLumiere
  • 4,461
  • 3
  • 8
  • 35