Angular 4日期管道,无时区 [英] Angular 4 date pipe, no timezone
问题描述
我正在使用日期管道在前端向用户显示记录日期.后端是从数据库获取日期的,其余时间是从服务器获取到前端的日期.我在那里:
I'm using date pipe to display record date to user on front-end. Back-end get's the date from DB and through rest I'm getting this from server to front-end. And there I use :
<div>{{myDate | date:'dd-MM-yyyy HH:mm:ss'}}</div>
问题是,这次是我自己不想的时区女巫.我需要将它设置为与从服务器获得的日期完全相同的日期.
The problem is, this time is with my own timezone witch I don't want. I need it to be the date exactly the same as I got from the server.
PS.我不能使用这样的东西:
PS. I can't use something like that :
let myDataWithoutLocal = formatMyDate(myDate);
因为日期来自多个对象,所以我真的想修改管道,而不是对象或其数据.
because date comes in multiple object's, so I would really like to modify the pipe, than the object or it's data.
推荐答案
我只是看到我的问题错过了解决方案.就是这样:
I just saw that my question missed a solution. So there it is :
当我在工作站上运行应用程序时,日期很好,但是当它在我们公司的服务器上运行时,发生了魔术. 解决方案:服务器选择了错误的时区.
The date was fine when I was running app on my workstation, but magic happened when it was running on our company's server. Solution : the server had wrong timezone selected.
谢谢!
这篇关于Angular 4日期管道,无时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!