xdan / datetimepicker

jQuery Plugin Date and Time Picker
https://xdsoft.net/jqplugins/datetimepicker/
MIT License
3.5k stars 1.51k forks source link

HTML 5, date-Input #272

Open Fruchuxs opened 9 years ago

Fruchuxs commented 9 years ago

Hello everyone,

first of all: nice work! It's a great datetimepicker. But i have one big problem: It seems, that the datetimepicker doesn't support HTML 5 date Inputs.

<input type="date" id="raid_end_date" name="example" required="required" value="2015-04-09">

If i click on a date in the picker, jquery prints the following line in my js console:

The specified value '02.06.2015' does not conform to the required format, 'yyyy-MM-dd'.

I think the problem is, that the value has the format "yyyy-MM-dd", but it's displayed in my local format (d.m.Y) through my browser.

Here is my JS Code:

    $('input[type="date"]').each(function(i, obj) {
        $(obj).datetimepicker({
            timepicker:false,
            format:'d.m.Y'
        });
    });

Any ideas to fix this?

Greetings, Fruchuxs

xdan commented 9 years ago

may be format:'Y-m-d' ? or better variant will be

 $('input[type="date"]').each(function(i, obj) {
       $(obj).attr('type', 'text');        
       $(obj).datetimepicker({
            timepicker:false,
            format:'d.m.Y'
        });
    });
IamMashed commented 6 years ago

Similar story but with the datetimepicker. <input class="form-control" id="date" name="date" type="text" value="2018-May-18 03:10"> My form does not pass validation with error Not a valid datetime value.

Console warning: The specified value "2018-May-18 03:10" does not conform to the required format. The format is "yyyy-MM-ddThh:mm" followed by optional ":ss" or ":ss.SSS".

My JS code:

$('input[type=datetime-local]') .attr('type', 'text') .datetimepicker({ inline:false, step: 5, format: 'Y-M-d H:i', });

If I make format 'Y-M-dTH:i' (with T between date and time) I am getting timezone inserted. Please help

AlecksJohannes commented 5 years ago

@IamMashed I fixed this problem by trying

$.datetimepicker.setDateFormatter('moment'); // Setup the date formatter

$('input[type=datetime-local]').datetimepicker({
     format: 'YYYY-MM-DDTHH:mm' 
})