Skip to content
This repository has been archived by the owner on Jun 22, 2018. It is now read-only.

Uncaught TypeError: Cannot read property 'getTime' of undefined #26

Open
shishtpal opened this issue Jun 16, 2018 · 4 comments
Open

Uncaught TypeError: Cannot read property 'getTime' of undefined #26

shishtpal opened this issue Jun 16, 2018 · 4 comments

Comments

@shishtpal
Copy link

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

@AuspeXeu
Copy link
Owner

AuspeXeu commented Jun 20, 2018

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

@shishtpal
Copy link
Author

OK Done

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

@AuspeXeu
Copy link
Owner

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

@shishtpal
Copy link
Author

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

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

No branches or pull requests

2 participants