Skip to content

Set 'Selected' and then Get 'Selected' does not return the same value UTC vs Local #562

@MartinMilata

Description

@MartinMilata

<input class="ngDate" type="text" ngxDaterangepickerMd [(ngModel)]="selected" (datesUpdated)="datesUpdated($event)" [timePicker]="true" [timePicker24Hour]="true" [locale]="localeConfig" showCancel="true" />

Create button and event where you will set the values for example: 17.5.2025 5h UTC

var a = new Date("2025-05-17T05:00:00.000Z");

this.selected = {
  startDate: dayjs(a),
  endDate: dayjs(a),
}

console.log('selected startDate', this.selected.startDate.toISOString());

In console will be: selected startDate 2025-05-17T05:00:00.000Z

ngx-daterangepicker-material in UI shows 2025-05-17 - 7h - my local time

Then open datepicker and click to done button to call datesUpdated event:
console.log('datesUpdated selected startDate', this.selected.startDate.toISOString());
console.log('datesUpdated event startDate', event.startDate.toISOString());

In console will be:
datesUpdated selected startDate 2025-05-17T07:00:00.000Z
datesUpdated event startDate 2025-05-17T07:00:00.000Z

My local time like UTC. There should be 2025-05-17T05:00:00.000Z UTC time which I set, not 7h

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions