How does vue use timestamps?

1. For the timestamp method found on the Internet, I put it separately in a js

export function formatDate(timestamp) {     
        var date = new Date(timestamp * 1000);//10*1000131000
        Y = date.getFullYear() + "-";
        M = (date.getMonth()+1 < 10 ? "0"+(date.getMonth()+1) : date.getMonth()+1) + "-";
        D = date.getDate() + " ";
        h = date.getHours() + ":";
        m = date.getMinutes() + ":";
        s = date.getSeconds();
        return Y+M+D+h+m+s;
}  

2. Introduce

into the XX.vue component
import {formatDate} from "@/assets/js/date.js"

3. For ease of use, the filter

is used.
filters:{
    //
    formatDate(time) {
        return formatDate(time);
    },
}

4. Use it in the list (using the elementUI framework)

<el-table-column prop="createTime" label="CREATETIME" sortable>
    <template slot-scope="scope">
        {{ scope.row.createTime|formatDate }}
    </template>
</el-table-column> 

5. Execution result

clipboard.png

what"s going on?


see if there is a problem with scope.row.createTime .


// 
export function formatDate(timestamp) {
  var date = new Date(timestamp * 1000);//10*1000131000
  var Y = date.getFullYear() + '-';
  var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
  var D = date.getDate() + ' ';
  var h = date.getHours() + ':';
  var m = date.getMinutes() + ':';
  var s = date.getSeconds();
  return Y+M+D+h+m+s;
}

y

y

m

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e83d3c-c87.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e83d3c-c87.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?