【发布时间】:2018-09-20 13:50:32
【问题描述】:
我想将 unix 时间戳(类似于 1537364040000)转换为 Date:Time String
为此,我做了类似的事情
this.selectedTime = new Date(this.selectedTime*1000);
(在此之前我的 this.selectedTime 是一个 unix 时间戳)
这应该 console.log 这样的东西
console.log(this.selectedTime) //Tue May 24 50687 17:30:00 GMT+0530 (India Standard Time)
console.log(typeof this.selectedTime) //Object
在上面,typeof 恰好是一个对象,我希望它是字符串,所以我这样做了
this.selectedTime = JSON.stringify(this.selectedTime)
这是 console.logging 类似的东西
console.log(this.selectedTime)
"+050687-06-10T20:40:00.000Z"
[问题:] 谁能帮我弄清楚我们怎样才能得到这样的东西 Tue May 24 50687 17:30:00 GMT+0530 或者这个 Tue May 24 50687 17:30:00 作为字符串?
[问题更新:]:也有人可以帮助弄清楚它记录的内容是 50687 而不是正确的年份(5 月 24 日星期二 50687强> 17:30:00)
我正在使用 coincap 历史 API http://coincap.io/history/1day/BTC
【问题讨论】:
-
typeof this.selectedTime.toString()? -
@ChrisSharp 我在这个问题中添加了 string 这个词
-
什么是日期时间字符串?您想要的是一个日期时间对象,然后您可能希望以某种方式呈现它。没有日期时间字符串这样的东西。
标签: javascript