datetimepicker: jquery.datetimepicker.js:1760 Uncaught TypeError: Cannot read property 'formatDate' of null at jquery.datetimepicker.js:1760

Hello, everyone. I searched the issues and found issue #573, has the solution to solve this. However, after applying the solution, the style of html is totally abnormal. My code is like this:

<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link ref="stylesheet" type="text/css" href="source/jquerydatetimepicker/jquery.datetimepicker.css">
  </head>
  <body>
    <input id="datetimepicker" type="text" >
  </body>
  <script src="source/jquery-3.1.0.js"></script>
  <script src="source/moment.js"></script>
  <script src="source/jquerydatetimepicker/jquery.datetimepicker.js"></script>
    <script>
      $.datetimepicker.setDateFormatter({
          parseDate: function (date, format) {
              var d = moment(date, format);
              return d.isValid() ? d.toDate() : false;
          },
          formatDate: function (date, format) {
              return moment(date).format(format);
          },
      });
      $('#datetimepicker').datetimepicker();
    </script>
</html>

Here is the source code. And it looks like this: datetimepickerror

About this issue

Most upvoted comments

I also met this issue, the solution was to include “jquery.datetimepicker.full.js” instead of “jquery.datetimepicker.js”.

Another good alternative might be this: https://github.com/flatpickr/flatpickr

The workaround also does not work properly for me. As with @ramwin’s screenshot, the minutes are shown as “i”. I think this project is dead. I’m now going to use this one myself.

I also met this issue, the solution was to include “jquery.datetimepicker.full.js” instead of “jquery.datetimepicker.js”.

I changed my code using jquery.datetimepicker.full.js but the html is still broken. Here is the code.

You can write $.datetimepicker.setDateFormatter(‘moment’); instead of $.datetimepicker.setDateFormatter be sure it work!

I switched from this project to date range picker, you can set singleDatePicker as true, then it works like a datetimepicker.