chat-date-format

消息聊天时间格式化

Usage no npm install needed!

<script type="module">
  import chatDateFormat from 'https://cdn.skypack.dev/chat-date-format';
</script>

README

安装:

npm i --save chat-date-format

调用:

chatDateFormat(timestamp, isDetail)

参数说明:

timestamp - 传入时间戳
isDetail - 是否要显示详细时间

使用:

  <script>
    let chatDateFormat = require('chat-date-format')

    methods: {
      ...chatDateFormat
    }

    created () {
      this.chatDateFormat(new Date()) // 当前格式化时间 - 某天 xx:xx
      this.chatDateFormat(new Date(), true) // 出当前格式化详细时间 - 某天 上午 xx:xx
    }
  </script>