1. 程式人生 > >時間戳格式化

時間戳格式化

gets created round info src .get ons class 技術

按照YYYY-MM-DD HH:mm:ss格式化時間

<template>
  <div></div>
</template>
<script>
export default{
  created() {
    this._getDate()
  },
  methods: {
    _getDate() {
      let now = new Date()
      console.log(now, now)
      let year = now.getFullYear()
      let month = now.getMonth() 
+ 1 let day = now.getDate() let hour = now.getHours() let minutes = now.getMinutes() let seconds = now.getSeconds() let time = year + - + month + - + day + + hour + : + minutes + : + seconds console.log(time) } } } </script>

技術分享圖片

時間戳格式化