4

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. 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.

Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234

2 Answers2

2

Try this:-

<!--output '2015-06-15 09:03 AM GMT+9'-->
<p>The custom date with fixed timezone is {{myDate  | date:'yyyy-MM-dd HH:mm a z':'+0900'}}</p>

Refer:- https://angular.io/api/common/DatePipe

Gourishankar
  • 906
  • 1
  • 7
  • 14
  • 1
    This only works if you don't have to deal with Daylight Savings Time, which many zones should have. – dloewen Feb 25 '20 at 20:36
-4

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.

Thank's!