Skip to content

Commit

Permalink
docs(moment-dateadapter): add docs for moment adapter options
Browse files Browse the repository at this point in the history
Describe how to set the MomentDateAdapter to parse dates as utc.
Describe the default behaviour of the MomentDateAdapter.
Add an example on how to configure MAT_MOMENT_DATA_ADAPTER_OPTIONS

Closes angular#7167
  • Loading branch information
Silthus committed Jun 5, 2018
1 parent 1577506 commit d0abfc9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lib/datepicker/datepicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ export class MyComponent {

<!-- example(datepicker-moment) -->

By default the `MomentDateAdapter` will creates dates in your time zone specific locale. You can change the default behaviour to parse dates as UTC by providing the `MAT_MOMENT_DATA_ADAPTER_OPTIONS` and setting it to `useUtc: true`.

```ts
@NgModule({
imports: [MatDatepickerModule, MatMomentDateModule],
providers: [
{ provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } }
]
})
```

It is also possible to create your own `DateAdapter` that works with any date format your app
requires. This is accomplished by subclassing `DateAdapter` and providing your subclass as the
`DateAdapter` implementation. You will also want to make sure that the `MAT_DATE_FORMATS` provided
Expand Down

0 comments on commit d0abfc9

Please sign in to comment.