kesarion / angular2-air-datepicker

Angular2 Datepicker | Native implementation of air-datepicker
http://t1m0n.name/air-datepicker/docs/
MIT License
16 stars 10 forks source link

How change the time? #29

Closed Spirka closed 4 years ago

Spirka commented 4 years ago

Why does the datepicker add 3 hours? And how to make sure not to add?

image

kesarion commented 4 years ago

That's just the thing, the datepicker does not add 3 hours, it works exclusively with UTC. It's JavaScript that adds or substracts time based on your timezone. The machine you're running this on (or the browser) must be set to GMT+0300, +3 hours. However, it's important to note that the Date Object still has the correct time, JS only displays it differently with console.log and other operations. You can study the subject further online and see what you want to do with the date and how to format it. I'd recommend mozilla for a comprehensive look at whatever subject you're dealing with or stackoverflow for specific questions.

Spirka commented 4 years ago

Thank you for answer. Can I use the Moment library insted of Date? Or String with UTC format?

kesarion commented 4 years ago

Well, you may not need moment.js. Regardless, this datepicker doesn't use any third party libraries, it gives you a Date (the exact selected date in UTC), which you can manipulate as required using your own choice of third party library; you just have to set it back as a Date object if you change it elsewhere.

Spirka commented 4 years ago

Thank you for explanations.