From ebbc1a1f39ceb03f4451e22b805cffdc5b2cdc20 Mon Sep 17 00:00:00 2001 From: Vasiliy Zverev Date: Wed, 6 Apr 2016 16:15:50 +0300 Subject: [PATCH] Corrected doc on using MomentJS for validation https://github.com/xdan/datetimepicker/issues/425#issuecomment-205888975 --- doc.tpl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc.tpl b/doc.tpl index d1d21a8..2e9222a 100644 --- a/doc.tpl +++ b/doc.tpl @@ -366,7 +366,8 @@ jQuery('#_datetimepicker_weekends_disable').datetimepicker({

By default, datetimepicker uses php-date-formatter for parsing and formatting the date and time displayed. You can replace the library by setting a custom DateFormatter. Simply supply an object that implements the parseDate and formatDate methods. This example uses the popular MomentJS library:

$.datetimepicker.setDateFormatter({
     parseDate: function (date, format) {
-        return moment(date, format);
+        var d = moment(date, format);
+        return d.isValid() ? d : false;
     },
     
     formatDate: function (date, format) {