Day incorrect in datepicker
Bug, feature request, or proposal:
When I select a date I see the correct date in the field but, when I save, the datepicker send the day before the date I have selected
here's the code:
<md-form-field> <input mdInput [(ngModel)]="fareCalendar.startDate" name="startDate" [mdDatepicker]="picker" placeholder="startDate"> <md-datepicker-toggle mdSuffix [for]="picker"></md-datepicker-toggle> <md-datepicker #picker></md-datepicker> </md-form-field>
I am using angular 4 and @angular/material": "^2.0.0-beta.10

but the date:

How can I send the UTC date
Could you try to reproduce it here, please: https://plnkr.co/edit/8nRKSJ?p=preview ?
I just want that the date I have selected in calendar is already in UTC timezone
That's why I'm asking you to reproduce it in the plunk. For me it's working fine, but it's possible that some bug is happening in your case:

If it's just a matter of configs, stackovervlow.com is more suitable than this channel.
The calendar returns a javascript Date object. What you've shown in above message seems like something generated from other source (it looks like a JSON.stringify() result or maybe from a database service). To get back the Javascript Date object, you have to do (really not sure how did you get that result):
fareCalendar.startDate = new Date(fareCalendar.startDate);
If I select th date: 6/9/2017 and print it I see:
Wed Sep 06 2017 00:00:00 GMT+0200
Then I save the date in a body const body = {
startDate: this.fareCalendar.startDate
};
And make post request.
I am using Http client
Oh, you may be refering to the fact that the UTC time add/subtract your current time offset. Look at the picture below: I'm in a GMT+2h00 zone, so, my UTC value is offset by 2 hours. So, if I set the hours to 23h00 in my Date object, my UTC date get offset to the day after (as in 1h00 am).

Yes, I want the date selected is already UTC, I used primeng calendar and there is a property like utc="true" that solve this.
If I select 22/9/2017 I want send: 2017-09-22T00:00:00.000Z
Well... I really don't know if it's planned to support such a utc attribute.
cc: @mmalerba
We do plan to add support for different timezones/offsets, but its not there yet. In the mean time you could make a custom DateAdapter that works with UTC dates to accomplish this.
Here is the DateAdapter class you would have to extend:
https://github.com/angular/material2/blob/master/src/lib/core/datetime/date-adapter.ts
Some examples of existing implementations: https://github.com/angular/material2/blob/master/src/lib/core/datetime/native-date-adapter.ts https://github.com/angular/material2/blob/master/src/material-moment-adapter/adapter/moment-date-adapter.ts
And some documentation that may help: https://material.angular.io/components/datepicker/overview https://blog.angular.io/taking-advantage-of-the-angular-material-datepicker-237e80fa14b3
@lippomano I have the same request. Did you get any solution about it ? thank you for any suggestions.
@we125182 I write a method that manipulate every date it is not the best practice but it's simpler for me
I'm also getting a incorrect date.

I get this exact same behaviour on https://material.angular.io/components/datepicker/overview It always adds +1 day after selected.
@adaojunior if you're seeing the same issue on the docs site its likely some issue related to your locale / time zone. Any additional information you can provide would be useful. If you're using Moment.js in your app (or willing to try it) you could give the MomentDateAdapter a try and see if it resolves your issue. Just add the MatMomentDateModule from @angular/material-moment-adapter at your application root instead of MatNativeDateModule
@mmalerba same issue on the docs, see:

I'm using MdNativeDateModule on my application.
@mmalerba Hello, is it possible to import MatMomentDateModule from @angular/material-moment-adapter when using beta12? I cannot find the way to do it, it's seems to me this module is not yet released?
@npen yeah I think it missed the release, you can install it from here in the mean time: https://github.com/angular/material2-moment-adapter-builds
Adding +1 day is a new "feature" with the day picker whilst using the default DateAdapter. I believe it has been introduced in beta 12.
This also happens for me on the material angular site: https://material.angular.io/components/datepicker/overview
Today is the 12th of October at 22:30. To replicate:
- Open the datepicker the 11 October is "circled" as today's date.
- Select the 12th, the 13th is displayed when the picker is closed.
- When I reopen it, the 12th is selected
I'm using an Aussie time zone. 22:30. When I switch back to Europe, it works as intended despite being on the same day as in Australia.
@jt-helsinki Thanks for the detailed info, strangely I am unable to reproduce it using the same settings. I tried 12th of October 2017 at 22:30 in the following time zones (all of the Australian ones listed on my system): Adelaide, Brisbane, Broken Hill, Currie, Darwin, Ecula, Hobart, Lindeman, Lord Howe, Melbourne, Perth, Sydney.
All of them showed the 12th circled and selected the 12th after clicking (on docs site)

If anyone knows what I'm doing wrong please let me know...
Looks like you're doing exactly what I was doing.
I notice I'm on a different OS. An unlikely shot, could it be a OS/browser thing?
I'm on: OSX Chrome (Version 61.0.3163.100 (Official Build) (64-bit))
Anyone else care to confirm?
The strange thing with this is that the date had not yet flipped to the following day. Europe and Australia were still on the same day.