[Vuejs]-How to show date in 13-digit Unix Timestamp format in JSpreadSheet?

0๐Ÿ‘

// Assuming your Unix Timestamps are stored in the `timestamp` column
const data = [
  { timestamp: 1629889200 },
  { timestamp: 1630158600 },
  
];


data.forEach(item => {
  item.formattedDate = new Date(item.timestamp * 1000).toLocaleDateString('en-US', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit'
  });
});


//Display in JSpreadSheet:
jspreadsheet(document.getElementById('spreadsheet'), {
  data: data,
  columns: [
    // ... other columns
    {
      title: 'Formatted Date',
      data: 'formattedDate'
    }
  ]
});

Leave a comment