bootstrap-datetimepicker icon indicating copy to clipboard operation
bootstrap-datetimepicker copied to clipboard

Uncaught TypeError: Cannot read property 'getTime' of undefined

Open shishtpal opened this issue 6 years ago • 4 comments

I am using this only as Time picker with format HH:ii P but when I dynamically change its value it throws this error

bootstrap-datetimepicker.min.js:formatted:431 Uncaught TypeError: Cannot read property 'getTime' of undefined
    at getDate (bootstrap-datetimepicker.min.js:formatted:431)
    at g.update (bootstrap-datetimepicker.min.js:formatted:624)
    at g.setStartDate (bootstrap-datetimepicker.min.js:formatted:497)
    at new g (bootstrap-datetimepicker.min.js:formatted:315)
    at HTMLInputElement.<anonymous> (bootstrap-datetimepicker.min.js:formatted:1432)
    at Function.each (jquery-2.1.3.min.js:2)
    at n.fn.init.each (jquery-2.1.3.min.js:2)
    at n.fn.init.d.fn.datetimepicker (bootstrap-datetimepicker.min.js:formatted:1427)
    at <anonymous>:1:3
getDate @ bootstrap-datetimepicker.min.js:formatted:431
update @ bootstrap-datetimepicker.min.js:formatted:624
setStartDate @ bootstrap-datetimepicker.min.js:formatted:497
g @ bootstrap-datetimepicker.min.js:formatted:315
(anonymous) @ bootstrap-datetimepicker.min.js:formatted:1432
each @ jquery-2.1.3.min.js:2
each @ jquery-2.1.3.min.js:2
d.fn.datetimepicker @ bootstrap-datetimepicker.min.js:formatted:1427
(anonymous) @ VM4937:1
Show 2 more blackboxed frames

When I inspected the error I found that this.date is undefined, Which is returned by getUTCDate Method

...
        getDate: function() {
            var i = this.getUTCDate();
            if (i === null) {
                return null
            }
            return new Date(i.getTime() + (i.getTimezoneOffset() * 60000))
        },
        getUTCDate: function() {
            return this.date
        },
...

Thanks

shishtpal avatar Jun 16 '18 05:06 shishtpal

Can you provide a jsfiddle to illustrate this? https://jsfiddle.net/AuspeXeu/sqwwcjzu/

AuspeXeu avatar Jun 20 '18 08:06 AuspeXeu

OK Done

$("#dtp").datetimepicker({
	startView: 'day',
	format: 'HH:ii p'
});

shishtpal avatar Jun 21 '18 07:06 shishtpal

Do you have you full code and could you please fork the jsfiddle and paste the link of an example here?

AuspeXeu avatar Jun 21 '18 07:06 AuspeXeu

Here it is https://jsfiddle.net/shishtpal/k2o5sn1q/

shishtpal avatar Jun 21 '18 15:06 shishtpal