M Zeinstra
M Zeinstra

Reputation: 1981

Datetimepicker doesn't use the given format

I'm currently using the Date time picker of JQuery, but it's not using the given format. Instead of using that, it uses it's default date format and gives an error in the console: Uncaught TypeError: F.mask.replace is not a function. I get this error when I lose focus of the Date time picker.

Something, though, I get another error right after the page loaded: maximum call stack size exceeded.

How do I make sure it uses the given format?

If you need any additional information, feel free to ask.

HTML

<input id="start" value="01-01-2016" />

CSS

$('#start').datetimepicker({
    formatTime: 'H:i',
    formatDate: 'dd-mm-yy',
    defaultDate: '01-01-2016',
    defaultTime: '10:00'
});

Additional information

This is the date time picker code that I use. The error (Uncaught TypeError: F.mask.replace is not a function) is on line 1743.

Upvotes: 0

Views: 1795

Answers (1)

Meiko Rachimow
Meiko Rachimow

Reputation: 4724

This is a bug in the master branch. It is already fixed, but still exists in the concatenated file jquery.datetimepicker.full.js. If you do not want to use this release versions, you could use the file jquery.datetimepicker.js and add the required dependencies:

If you use bower, you could add the dependencies from here https://github.com/xdan/datetimepicker/blob/master/bower.json to your own bower.json:

"jquery": ">= 1.7.2",
"jquery-mousewheel": ">= 3.1.13",
"php-date-formatter": ">= 1.3.3"

or:

<link href="https://rawgit.com/xdan/datetimepicker/master/jquery.datetimepicker.css"  type="text/css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-2.2.2.min.js"></script>
<script src="https://rawgit.com/jquery/jquery-mousewheel/master/jquery.mousewheel.min.js"></script>
<script src="https://rawgit.com/kartik-v/php-date-formatter/master/js/php-date-formatter.min.js"></script>
<script src="https://rawgit.com/xdan/datetimepicker/master/jquery.datetimepicker.js"></script>

<input id="start" value="01-01-2016" />
<script>
  $( document ).ready(function() {
    $('#start').datetimepicker({
      formatTime: 'H:i',
      formatDate: 'dd-mm-yy',
      defaultDate: new Date(2016,01,01),
      defaultTime: '10:00'
    });
  });

</script>

Upvotes: 1

Related Questions