Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
roma2341 opened this issue Sep 13, 2023 · 3 comments
Open

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

roma2341 opened this issue Sep 13, 2023 · 3 comments

Comments

@roma2341
Copy link

roma2341 commented Sep 13, 2023

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 roma2341 changed the title 6 versions ngModelChange returns values in wrong time-zone 6 version ngModelChange returns values in wrong time-zone Sep 13, 2023
@roma2341
Copy link
Author

roma2341 commented Sep 19, 2023

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

valnoel pushed a commit to media-cloud-ai/ex_backend that referenced this issue Oct 25, 2023
datepicker package is not taking timezone in
time selection. It is a known issue, waiting for
correction in the main package.
cf. fetrarij/ngx-daterangepicker-material#533
@gitliyu
Copy link

gitliyu commented Nov 13, 2023

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

@tampambro
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants