Convert a Unix timestamp to time in JavaScript

前端 未结 29 2214
渐次进展
渐次进展 2020-11-21 04:57

I am storing time in a MySQL database as a Unix timestamp and that gets sent to some JavaScript code. How would I get just the time out of it?

For example, in HH/MM/

29条回答
  •  猫巷女王i
    2020-11-21 05:19

    moment.js

    convert timestamps to date string in js

    https://momentjs.com/

    moment().format('YYYY-MM-DD hh:mm:ss');
    // "2020-01-10 11:55:43"
    
    moment(1578478211000).format('YYYY-MM-DD hh:mm:ss');
    // "2020-01-08 06:10:11"
    
    
    

提交回复
热议问题