Angular Material Datepicker not keeps local timezone

158 views Asked by At

I have such code:

<mat-form-field class="example-full-width">
                <input
                  [matDatepicker]="picker"
                  formControlName="from"
                  matInput
                />
                <mat-datepicker-toggle [for]="picker" matSuffix></mat-datepicker-toggle>
                <mat-datepicker #picker></mat-datepicker>
</mat-form-field>
<div>{{element.get('from').value.toISOString()}}</div>
<div>{{element.get('from').value}}</div>
this._formBuilder.group({
        from: [moment(source.from).local()]
})

I want that user will work with local timezone, but on server I want to send zero UTC offset.
Initially, it shows the correct date
enter image description here
But when I choose a different date from datepicker, it clears timezone from date for some reason. I don't need it.
enter image description here
Why it can be happening?

1

There are 1 answers

0
IngBond On

That was because of moment.tz.setDefault