gpt4 book ai didi

date - Angular 2 日期管道添加或子小时

转载 作者:太空狗 更新时间:2023-10-29 18:32:04 27 4
gpt4 key购买 nike

我对新的 Angular 2 Date Pipe 有疑问。

我有一个日期值是;

let myDate = '2017-01-31T17:53:36'

并且我使用 Date Pipe 作为格式化程序以像这样显示在 View 中;

{{myDate | date: 'dd/MM/yyyy HH:mm' }}

但它显示的是本地时间,增加了 3 小时。

31/01/2017 20:53

我想显示确切的时间;

31/01/2017 17:53

我该怎么做?

最佳答案

希望对您有所帮助: https://www.reddit.com/r/Angular2/comments/4so1j7/how_to_set_locale_for_datepipe/

This is a pipe, there for you use it in your template. Basically in my case, my webApi returns full date format (ie. Tue Dec 15 2015 13:30:32 GMT-0500 (Eastern Standard Time)). So in my pipe I do new Date(value) which will create a javascript Date object from the string. If your date returned from the http call doesn't contain any localisation information, then the parsed date will be taken like if it was in your current timezone.

关于date - Angular 2 日期管道添加或子小时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42028699/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com