greengerong / rebirth-ng

rebirth-ng is a ui framework for Angular & bootstrap.
https://greengerong.github.io/rebirth-ng/
MIT License
116 stars 21 forks source link

time-picker 获取到的时间会少8个小时。 #15

Closed zxdmrg closed 7 years ago

zxdmrg commented 7 years ago

time-picker 获取到的时间会少8个小时。 2017-05-26T12:59:00.000Z.请问怎么格式化返回的时间

greengerong commented 7 years ago

请问:是DatePicker还是TimePicker,TimePicker默认返回的为{hour,minute,second}对象,而不是Date类型。 如果是DatePicker的话,如果你需要支持time zone,则注意utc时间。

greengerong commented 7 years ago

@zxdmrg 还有什么问题?

zxdmrg commented 7 years ago

@greengerong 不好意思,这么晚才回复。我用的是DatePicker。他返回的是Date类型。在浏览器的console里面调试他是正常的带时区的时间。但是我把它转换成json的时候它会自动变成不带时区的。导致时间不对。可以设置他的时区吗?

greengerong commented 7 years ago

这不是组件的问题,应该是你的Date pipe的问题,尝试先to utc时间试试。如果是angular2的DatePipe,则尝试设置time zone:[https://angular.io/docs/ts/latest/api/common/index/DatePipe-pipe.html][https://angular.io/docs/ts/latest/api/common/index/DatePipe-pipe.html]

@zxdmrg

greengerong commented 7 years ago

@zxdmrg 问题解决了? 先关闭该问题了。有任何问题可以继续提问。