Convert a Unix timestamp to time in JavaScript

前端 未结 29 2093
渐次进展
渐次进展 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条回答
  •  情书的邮戳
    2020-11-21 05:25

    shortest one-liner solution to format seconds as hh:mm:ss: variant:

    console.log(new Date(1549312452 * 1000).toISOString().slice(0, 19).replace('T', ' '));
    // "2019-02-04 20:34:12"

提交回复
热议问题