Yes, it's possible you need to calculate time zone offset and add then add to your date object time sample code is given below.

var d = new Date('2016-06-15 10:59:53.5055');
    var timeZoneDifference = (d.getTimezoneOffset() / 60) * -1; //convert to positive value.
    d.setTime(d.getTime() + (timeZoneDifference * 60) * 60 * 1000);
    d.toISOString()
Answer from Narayan Sikarwar on Stack Overflow
🌐
Telerik
telerik.com › knowledge base › managing time zones with the dateinputs components
Angular Managing Time Zones with the DateInputs Components - Kendo UI for Angular
January 20, 2026 - As a result, the applied time offset ... details, see the following GitHib issue. To remove the time zone information from a Date object, use the toISOString() method....
🌐
Syncfusion
ej2.syncfusion.com › angular › documentation › schedule › timezone
Timezone in Angular Schedule component | Syncfusion
Removes the local timezone offset from the given date. ... // Assume your local timezone as IST/UTC+05:30 let timezone: Timezone = new Timezone(); let date: Date = new Date(2018,11,5,15,25,11); let convertedDate: Date = timezone.removeLocal...
🌐
Reddit
reddit.com › r/angular2 › using angular date pipe will convert my time, how can i prevent the conversion?
r/Angular2 on Reddit: Using Angular date pipe will convert my time, how can I prevent the conversion?
April 6, 2021 -

I have a time stamp that I got from the server side.

The time before using the date pipe is : 2021-04-01T20:45:30.279+0000 ( html code:

<td mat-cell \*matCellDef="let element"> {{element.when }} </td> )

The time after I used date pipe: 01-Apr-2021 13:45:30

( html code: <td mat-cell *matCellDef="let element"> {{element.when | date: 'dd-MMM-yyyy HH:mm:ss'}} </td> )

The hour is different after using the date pipe. How can I stop it's conversion?

Thank you!

🌐
DEV Community
dev.to › shubhampatilsd › removing-timezones-from-dates-in-javascript-46ah
Removing Timezones from Dates in Javascript - DEV Community
April 23, 2023 - First tzoffset initializes a new Date and get the timezone offset in milliseconds (in my case, it would be 28800000 milliseconds). Then, we subtract that from the value of date, which was 10:30 PM, so it would now be 4:30 PM.
🌐
Reddit
reddit.com › r/angular › formatting dates/times in specified timezone
r/angular on Reddit: Formatting Dates/Times in Specified Timezone
September 15, 2022 -

Hi all,

I've got myself in a bit of a pickle, and I'm hoping you kind souls can give me some advice.

I have an application where I want to show the time of an event in a specific time zone (this is neither UTC or local time). I've done this before using moment, but as it is in maintenance mode, I need to move on from it - I have currently been using Luxon, but this can be changed if other libraries are the answer.

My situation:

  • I start with a number, representing the number of milliseconds since the start of the epoch. This is read from a database (sample value: 1659222000000 - representing Saturday, 30 July 2022 23:00:00 in UTC/GMT)

  • I am in "Europe/London" time zone (Sunday, 31 July 2022 00:00:00)

  • I want to output the date/time for the "America/New_York" time zone (regardless of my browsers time zone: Saturday, 30 July 2022 19:00:00)

Does anyone have any bright ideas for how I can get it to show the time in New York instead of the time in London?

Thank you in advance!

Find elsewhere
🌐
Plunker
embed.plnkr.co › plunk › ksXqXp
Angular strap timezones solved - Plunker
Did you forget to include moment-timezone.js?'); } } return aMoment; } }]) .filter('ngmDateFormat', ['moment', 'ngmTimeCalc', 'ngMomentConfig', function (moment, ngmTimeCalc, ngMomentConfig) { function ngmDateFormatFilter(value, format, timezone, preprocess) { if (typeof value === 'undefined' || value === null) { return ''; } var date; var preprocessedValue; if (typeof value === 'string') { preprocessedValue = ngmTimeCalc.preprocessDate(value, preprocess,'YYYY-MM-DDTHH:mm:ss'); date = moment(preprocessedValue); if (!date.isValid()) { return ''; } } else if (Object.prototype.toString.call(value
🌐
Angular
v17.angular.io › api › common › formatDate
Angular
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
Top answer
1 of 3
47

The issue isn't AngularStrap. Its just how javascript dates work and how JSON formats them for transmission. When you turn a javascript date object into a JSON string, it formats the string as UTC.

For example, I'm in Utah and it is now 07:41 on 2013-10-24. If I create a new javascript date and print it to the console it will say:

Thu Oct 24 2013 07:41:19 GMT-0600 (MDT)

If I stringify that same date (using JSON.stringify(date), I get:

"2013-10-24T13:41:47.656Z"

which you can see is not in my current timezone, but is in UTC. So the conversion is happening just before the form gets sent to the server when it gets converted from a javascript object to a JSON string.

The easiest way to do it would be to just change the date to a string of your own choosing prior to sending the date to the server. So instead of letting JSON change the date to UTC, (assuming you don't care about the time of day) you could just do something like this:

var dateStrToSend = $scope.date.getUTCFullYear() + '-' + ($scope.date.getUTCMonth() + 1) +  '-' + $scope.date.getUTCDate();

That will give you a UTC-based string that looks like '2013-10-24' and then you can send that to the server, instead of the JSON format which includes the time info. Hopefully that helps.

UPDATE: As @Matt Johnson said, there are two ways to do it. You said: How could we prevent the conversion, or use UTC dates during the whole process?. If you want to use UTC, then use my above explanation. If you want to just "prevent the conversion", you could use the following:

var dateStrToSend = $scope.date.getFullYear() + '-' + ($scope.date.getMonth() + 1) +  '-' + $scope.date.getDate();
2 of 3
17

A bit late but I spent my afternoon on this and someone might find it useful.

Another way to do this declaratively is to use the dateType, dateFormat and modelDateFormat attributes. Set these in either the config or the HTML e.g

angular.module('app').config(function ($datepickerProvider) {
    angular.extend($datepickerProvider.defaults, {
        dateFormat: 'dd-MMMM-yyyy',
        modelDateFormat: "yyyy-MM-ddTHH:mm:ss",
        dateType: "string"
    });
});

DateFormat is the format the date will be displayed to the user in the date picker while modelDateFormat is the format it will be converted to before being bound to your model.

I also had default values coming from the server which I needed to be bound to the datepicker on page load. I therefore had to update the format the server serialized dates in JSON to match the modelDateFormat. I am using Web API so I used the below.

var jsonSettings = Formatters.JsonFormatter.SerializerSettings;
jsonSettings.DateFormatString = "yyyy-MM-ddTHH:mm:ss";
🌐
GitHub
github.com › angular › angular › issues › 49540
Datepipe formating with timezone - incorrect date in date when is winter time changed to summer time · Issue #49540 · angular/angular
March 22, 2023 - this.dates.push(new Date('2022-03-27T00:00:00.000Z')); this.dates.push(new Date('2022-03-27T01:00:00.000Z')); this.dates.push(new Date('2022-03-27T02:00:00.000Z')); this.dates.push(new Date('2022-03-27T03:00:00.000Z')); this.dates.push(new Date('2021-03-28T00:00:00.000Z')); this.dates.push(new Date('2021-03-28T01:00:00.000Z')); this.dates.push(new Date('2021-03-28T02:00:00.000Z')); this.dates.push(new Date('2021-03-28T03:00:00.000Z')); this.dates.push(new Date('2020-03-29T00:00:00.000Z')); this.dates.push(new Date('2020-03-29T01:00:00.000Z')); this.dates.push(new Date('2020-03-29T02:00:00.000Z
Author   MartinMilata
Top answer
1 of 4
97

Since version 1.3.0 AngularJS introduced extra filter parameter timezone, like following:

{{ date_expression | date : format : timezone}}

But in versions 1.3.x only supported timezone is UTC, which can be used as following:

{{ someDate | date: 'MMM d, y H:mm:ss' : 'UTC' }}

Since version 1.4.0-rc.0 AngularJS supports other timezones too. I was not testing all possible timezones, but here's for example how you can get date in Japan Standard Time (JSP, GMT +9):

{{ clock | date: 'MMM d, y H:mm:ss' : '+0900' }}

Here you can find documentation of AngularJS date filters.

NOTE: this is working only with Angular 1.x

Here's working example

2 of 4
31

The 'Z' is what adds the timezone info. As for output UTC, that seems to be the subject of some confusion -- people seem to gravitate toward moment.js.

Borrowing from this answer, you could do something like this without moment.js:

controller

var app1 = angular.module('app1',[]);

app1.controller('ctrl',['$scope',function($scope){

  var toUTCDate = function(date){
    var _utc = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(),  date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
    return _utc;
  };

  var millisToUTCDate = function(millis){
    return toUTCDate(new Date(millis));
  };

    $scope.toUTCDate = toUTCDate;
    $scope.millisToUTCDate = millisToUTCDate;

  }]);

template

<html ng-app="app1">

  <head>
    <script data-require="angular.js@*" data-semver="1.2.12" src="http://code.angularjs.org/1.2.12/angular.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
  </head>

  <body>
    <div ng-controller="ctrl">
      <div>
      utc {{millisToUTCDate(1400167800) | date:'dd-M-yyyy H:mm'}}
      </div>
      <div>
      local {{1400167800 | date:'dd-M-yyyy H:mm'}}
      </div>
    </div>
  </body>

</html>

here's plunker to play with it

See also this and this.

Also note that with this method, if you use the 'Z' from Angular's date filter, it seems it will still print your local timezone offset.

🌐
Stack Overflow
stackoverflow.com › questions › 33787758 › ignoring-time-zone-in-date-object-returned-from-an-api-using-angular
Ignoring time zone in date object returned from an API using Angular
When I display the date I use two filters, mine and the angular date filter to properly format it. <span class="list-content col-sm-6">{{appointment.ApptDateTime | formattedDate | date:'MMM dd, yyyy hh:mm a'}}</span> The problem I'm having is the time is adjusting based off the users current time zone. I want to ignore this and instead use the value as it's returned with out altering it. I notice that depending on the timezone of the computer the response from the API changes the returned date.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getTimezoneOffset
Date.prototype.getTimezoneOffset() - JavaScript | MDN
const date1 = new Date("August 19, 1975 23:15:30 GMT+07:00"); const date2 = new Date("August 19, 1975 23:15:30 GMT-02:00"); console.log(date1.getTimezoneOffset()); // Expected output: your local timezone offset in minutes // (e.g., -120). NOT the timezone offset of the date object.
🌐
Telerik
telerik.com › components › date math › timezones
Angular Date Math Timezones - Kendo UI for Angular
The Date Math package enables you to load a timezone data for a specific city, continent, or for the whole world. This could be used for adding or removing a specific time offset from the JavaScript Date value.