uxsolutions / bootstrap-datepicker

A datepicker for twitter bootstrap (@twbs)
Apache License 2.0
12.66k stars 6.06k forks source link

Add support for timestamp in milliseconds since January 1, 1970, 00:00:00 UTC. #1518

Open ghost opened 9 years ago

ghost commented 9 years ago

To avoid timezone problems, my intention was to set the dates using a javascript Date object using an ISO-8601 string:

    $('#calendar-container .calendar').datepicker({
        startDate: Date.parse("2015-08-06T09:15:19+02:00"),
        datesDisabled: [ Date.parse("2015-08-07T09:15:19+02:00") ],
        todayHighlight: true,
    });

But this fails with this error:

Uncaught TypeError: date.match is not a function

After some research, I think this happens because https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse returns the time as timestamp in milliseconds since January 1, 1970, 00:00:00 UTC when giving the ISO-8601 as string to parse.

Could you add support for this format?

hebbet commented 9 years ago

Feel free to provide a PR ;-)

maybe we will look into it for 2.0

ghost commented 9 years ago

Glad to hear you might look into it. For now, I revert back to a string, no time to dive into a PR.