fetrarij / ngx-daterangepicker-material

Pure Angular 2+ date range picker with material design theme, a demo here:
https://fetrarij.github.io/ngx-daterangepicker-material/
MIT License
246 stars 247 forks source link

Selected Dates are not UTC Dates #547

Open pigeonfield opened 3 months ago

pigeonfield commented 3 months ago

Versions

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots

  1. I select some date range with time:

image

  1. Then displaying in the console event emitted by date&time selection:

image

ISSUE: I am already getting local date time, instead of UTC time. So in my case (Europe/Vienna) I am actually getting +1h time when passing values further.

Stackblitz link If applicable, add stackblitz link.

MatteoGalletta commented 2 months ago

Here's my ugly workaround:

StackBlitz

Essentially I'm parsing the UTC date as a local one (obtaining the correct one):

onChange(event: any) {
    this.selectedValue = event;

    this.selectedValue.startDate = moment(this.selectedValue.startDate.toDate().toISOString().substring(0, 23)); // new line
    this.selectedValue.endDate = moment(this.selectedValue.endDate.toDate().toISOString().substring(0, 23)); // new line

    console.log('on change event', event);
}