There is any way to configure the md-datepicker to start week on monday? By default it start on Sunday and there isn't any specification who to change this.
5 Answers
You have to build a custom DateAdapter
. A custom DateAdapter is a class which implements the DateAdapter
interface (it's actually an abstract class that should be extended). It must have a bunch of predefined function implementations and have to be registered as a useClass
for the DateAdapter
provider.
providers: [{provide: DateAdapter, useClass: CustomDateAdapter }]
The date adapter tells the datepicker things like how to store dates/times internally, how to present them in the input and other things.
Material provided four classes which extends the DateAdapter
abstract class: NativeDateAdapter
, MomentDateAdapter
, LuxonDateAdapter
and DateFnsAdapter
. They tell MatDatepicker
how to work with the javascript native Date
object and moment
object, respectively. I'll talk about the javascript native Date
object, but the same principles apply to any date representation. The javascript Date
object has some limitations (for example, it's not possible to tell it how do you want to present dates). The long story short: just extends the Material provided NativeDateAdapter
and override the functions you need. What you want to do is shown in this stackblitz demo (basically you want to override a function of the NativeDateAdapter
: getFirstDayOfWeek : () => number
) and I'll give a little overview afterwards.
getFirstDayOfWeek(): number {
return 1;
}
In the demo, you will see a custom-date-adapter.ts
. This is where you should extended the NativeDateAdapter
, overriding two functions:
1) parse: (value: any) => Date | null
2) getFirstDayOfWeek: ()=> number
The first function meant to a) among other things, create a Date
object from what the user chose in the calendar, and b) parse what is typed in the input to a Date
object.
The second function (getFirstDayOfWeek
) tells the calendar to start in a specifc week day (0 - Sunday, 1 - Monday, 2 - Tuesday ...).
Also there's an interesting format: (date: Date, displayFormat: Object) => string
function available to be implemented/overriden that allows you to define the format the date string must be shown in the input after being selected from the calendar popup.
In the demo, in the main.ts you must tell Angular that there is a custom date adapter to use (look at the providers array). In this case, I built this demo to work with Brazilian Portuguese (look at the main.ts constructor, for the date.setLocale('pt-BR')
). Over here, we present dates as dd/MM/yyy
, knowing Monday == "Segunda-Feira" in portuguese. :D
The other pre-built adapter (MomentDateAdapter
, based on Moment.js
instead of just the native Date
object) that, in some cases, saves you from building a custom date adapter, as Moment.js
already deals with locales in a more efficient way).
Hope it helps.

- 8,954
- 2
- 33
- 55
-
1this is not working for me. My datepicker is injectable but is never instantiated: https://stackoverflow.com/questions/65104948/angular-9-how-to-get-extended-locale-aware-start-of-week-nativedateadapter-w – dermoritz Dec 02 '20 at 09:13
-
The code in the link worked for me with two adjustments: had to add override keyword to make the override functions work, and change "getFirstDayOfWeek" to return 1 as the question asked for monday as first day. – Asaf M Oct 25 '22 at 14:43
-
Thanks for the heads-up, @AsafM. I've updated the stackblitz demo with the `override` decorator. – julianobrasil Oct 27 '22 at 12:49
In case if anyone using <ngx-mat-datetime-picker>
and wanted to achieve start a week from Monday instead of Sunday.
app.module.ts
providers:[{ provide: NgxMatDateAdapter, useClass: CustomDateAdapter}]
custom.date.adapter.ts
import { NgxMatNativeDateAdapter } from '@angular-material-components/datetime-picker';
import { Injectable } from "@angular/core";
@Injectable()
export class CustomDateAdapter extends NgxMatNativeDateAdapter {
getFirstDayOfWeek(): number {
return 1;
}
}
-
Don't forget to add the @Injectable() annotation to avoid the future warning. – Andrew Jul 24 '21 at 09:54
If the solution from @julianobrasil doesn't work for someone, you can try this:
If you have multiple sub modules in your project, where one of them uses the Material DatePicker, then make sure that none of the SubModules imports the MatNativeDateModule
. This module provides its own DateAdapter
, which may overwrite your own DateAdapter
from app.module.ts
.

- 341
- 9
- 21
Based on @julianobrasil https://stackoverflow.com/a/45020144/6052406
Create the class custom-date-adapter.ts to override getFirstDayOfWeek()
import { NativeDateAdapter } from '@angular/material/core';
export class CustomDateAdapter extends NativeDateAdapter {
override getFirstDayOfWeek(): number {
return 1;
}
}
In app.module.ts, import (at least) the following:
import { MatDatepickerModule } from '@angular/material/datepicker';
import { CustomDateAdapter } from './custom-date-adapter';
import { DateAdapter, MatNativeDateModule } from '@angular/material/core';
Add in imports:
MatDatepickerModule
MatNativeDateModule
Add in providers:
providers: [
{ provide: DateAdapter, useClass: CustomDateAdapter }
]
Voilá!

- 81
- 1
- 3
For luxon-date-adapter it's simply like:
providers: [
{ provide: DateAdapter, useValue: new LuxonDateAdapter('en-GB', {
firstDayOfWeek: 1,
useUtc: true
}) },
]
All available options: https://github.com/angular/components/blob/main/src/material-luxon-adapter/adapter/luxon-date-adapter.ts#L18

- 11
- 2