Search code examples
javascripttimezonemomentjsdst

Daylight Saving Time for selected location and date


I need get DST(Daylight Saving Time) true or false to selected date and selected city

I have form with two input fields and one output

First input field: user input city (using google maps places autocomplete ) Second input field: calendar (using datepicker)

Output: user get in selected city and selected date is DST or not, example: London, 2015/06/22 - DST true or Berlin, 2015/11/11 - DST false

I try momentjs: moment([year, month, day]).isDST() - not working (only for user location)

Thank you


Solution

  • The timezone moment.js plugin allows you to do it, as you can read in this answer. The problem is that you will need to know on which time-zone that city is located.

    To get to know the time-zone for a location on the earth, you can use the Google Time Zone API. Now the problem is that you need to provide the specific Latitude/Longitude pair.

    To do so, you can use Google Maps API.

    It is not very straightforward though :)