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

pass time zone dynamically in component #397

Open ravikandpal31 opened 2 years ago

ravikandpal31 commented 2 years ago

I am facing issue related to timezone handling in this component. Is there any options available to pass timezone to the component. Or is there any other way to display selected date in a particular timezone.

marten790 commented 1 year ago

having same issue. Had to do big workaround to get things semi working Setting the date before passing it into the date picker startDate: dayjs().tz('Australia/Sydney'), endDate: dayjs().tz('Australia/Sydney'),

Converting it to UTC after getting the value from the date picker // if a new date is selected ngx-daterangepicker-material converts the date time back to your local time. // to fix this you pass true as a second value in .tz options so it changes the timezone but not the time // https://day.js.org/docs/en/timezone/converting-to-zone for more information // then convert to utc format for api let startDate = dayjs(valueFromForm.startDate) .tz('Australia/Sydney', true) .utc() .format(); let endDate = dayjs(valueFromForm.endDate) .tz('Australia/Sydney', true) .utc() .format();