2016-09-30 1 views
0

datetimepickerを使用しようとしています。他の場所では、日付時刻の書式設定にmomentjを使用します。xdan/datetimepickerはデフォルトで "php-date-formatter"を使用します - "Highlighted days"機能が動作しません。

There is my plunker example。 DateTimePickerのため

Date.parseDate = function (input, format) { 
    return moment(input, format).toDate(); 
}; 
Date.prototype.dateFormat = function (format) { 
    return moment(this).format(format); 
}; 

使用momentjs形式:

format: "DD/MM/YYYY H:mm:ss", 
formatTime: 'H:mm', 
formatDate: 'DD/MM/YYYY', 

しかし瞬間を使用した場合、 "強調表示の日" 機能が動作しません。

"ハイライトされた日"機能が動作するようにするにはどうすればよいですか?解決策が見つかりました

答えて

0

$(document).ready(function() { 

    var myFormatter = { 
    parseDate: function(vDate, vFormat) {   
     return moment(vDate, vFormat).toDate(); 
    }, 
    guessDate: function(vDateStr, vFormat){   
     return moment(vDateStr, vFormat).toDate(); 
    }, 
    parseFormat: function(vChar, vDate){   
     return vDate; // date string (I guess) 

    },   
    formatDate: function(vChar, vDate) {    
     return moment(vChar).format(vDate); 
    }, 

    }; 

    jQuery.datetimepicker.**setDateFormatter**(myFormatter); 


    jQuery('#datetimepicker').datetimepicker({ 
    timepicker: true, 

    // 'd/m/y'format is requared for datetimepicker days HIGHLIGHT function to work!!! 
    //Date, time formating: http://php.net/manual/en/function.date.php 
    step: 15, 
    /* 
    // momentJs formating 
    format: "d/m/Y H:i:s", 
    formatTime: "H:i", 
    formatDate: "d/m/Y", 
    */ 

    format: "DD/MM/YYYY H:mm:ss", 
    formatTime: 'H:mm', 
    formatDate: 'DD/MM/YYYY', //I need to use this format, but it works only when using "d/m/Y" - so somewhere the php date formater is still used.. 

    highlightedDates: [ 
     "01/09/2016,,xdsoft_highlighted_mint", 
     "02/09/2016,,xdsoft_highlighted_mint", 
     "03/09/2016,,xdsoft_highlighted_mint", 
     "06.09/2016", 
     "07.09.2016", 
     "08.09.2016", 
     "12.09.2016,Christmas Eve,xdsoft_highlighted_mint", 
     "13.09.2016,Christmas Day,xdsoft_highlighted_mint", 
     "14.09.2016,Christmas Day,xdsoft_highlighted_mint", 
     "26.09.2016,,xdsoft_highlighted_mint" 
    ] 
    }); 

There is working plunker example

主な問題はあるが、私の場合ですが... browserify /一気モジュール連結され、そのDateTimePickerのはjqueryの下に定義されていない...

ので、 WebPackに建物を変更しようとしています....

関連する問題