0

Im trying to make a table with vue.js and one of the row is supposed to print a date i receive in epoch time. but fail to convert it in a readable date and just get "invalide date" printed on my browser.

Here is how i convert it

  var sec = 1588351494;
    var tmp =new Date(0);
    tmp.setUTCDate(sec);
    var res= tmp;

her is how it's made to be able to be called as a vue.js object

      return {
        tableData: [
          {
            uid: '01020304050607',
            lastReadDate: res,
          },
        ]
      }

And then i simply print it in my html page doing this, which print the "invalide date" in the row.

          <td>
            {{row.lastReadDate }}
          </td>
shas
  • 378
  • 4
  • 20

1 Answers1

0
var sec = 1588351494;
var res =new Date(sec * 1000);  // multiply seconds with 1000 to convert it to ms.

Check the fiddle: https://jsfiddle.net/vf74h5n0/4/

To format date in "DD/MM/YYYY" you can use momentjs.

var date = new Date(1588351494 * 1000);
moment(date).format("DD/MM/YYYY");

Here is a example https://jsfiddle.net/vf74h5n0/5/

Mahmudur Rahman
  • 745
  • 5
  • 13