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

6 version ngModelChange returns values in wrong time-zone #533

Open roma2341 opened 9 months ago

roma2341 commented 9 months ago

it should return values in local timezone. But instead it adds +3 hours. My timezone is (+3). So when I pick 19:00. It saves it as 19:00(But in UTC, not in my timezone). And js date show me 22:00 because of that. Why ? and how to fix this behavior to make it like version 5 ?

roma2341 commented 9 months ago

If anybody needs this library in local time instead of UTC I created this package as a temporary solution until the authors provide a logic to set any timezone: https://www.npmjs.com/package/ngx-daterangepicker-material-no-utc

gitliyu commented 7 months ago

Same problem, the downgraded version to 5 is fine. May I ask when the new version will be repaired

tampambro commented 5 months ago

My solution of this problem. I write value from datepicker using this function.

function getDate(date: dayjs.Dayjs): string {
  return dayjs(
    date?.format('YYYY-MM-DD HH:mm:ss'),
    'YYYY-MM-DD HH:mm:ss',
  )
    .format('YYYY-MM-DDTHH:mm:ssZ');
}

As far as I understand, problem in uncorrect UTC, because in library utc is hard coded in zero zone. If do something like this, dateFromPicker.local().format()- we get not present time in locale zone, but get zero utc time in our time zone. Or something)))

I think it would be better if datepicker had flag isUtc. Default it can be true.