datetimepicker icon indicating copy to clipboard operation
datetimepicker copied to clipboard

Range between date work only with format "Y/m/d"

Open prosto-chewey opened this issue 10 years ago • 12 comments

If I run picker with date format 'd.m.Y' - range from example ( http://xdsoft.net/jqplugins/datetimepicker/#range ) not work

prosto-chewey avatar Mar 24 '14 13:03 prosto-chewey

I have the same problem. Range does not work with format "Y-m-d H:i:s" nor "Y-m-d". It only allows to select previous/following month, not date in that month.

Is there some workaround?

escopecz avatar May 03 '14 14:05 escopecz

Same problem here.

When Using 'Y-m-d H:i
Today: June 11 if I FIRST select End Date (June 06), then i can select as Start Date all the days until Today (June 11)

$('#fechaAgendaInicio').datetimepicker({ lang: 'es', //format: 'Y-m-d H:i', dayOfWeekStart: 1, //step: 15, format:'Y/m/d', timepicker:false, onShow: function(ct) { this.setOptions({ maxDate: $('#fechaAgendaFin').val()?$('#fechaAgendaFin').val():false }) } });

                    $('#fechaAgendaFin').datetimepicker({
                        lang: 'es',
                        //format: 'Y-m-d H:i',
                        dayOfWeekStart: 1,
                        //step: 15,
                        format:'Y/m/d',
                        timepicker:false,
                        onShow: function(ct) {
                            this.setOptions({
                                minDate: $('#fechaAgendaInicio').val()?$('#fechaAgendaInicio').val():false
                            })
                        }
                    });

pakoArtal avatar Jun 11 '14 17:06 pakoArtal

I think I have a solution: On file jquery.datetimepicker.js v2.2.9 change :

line 913 maxDate = _xdsoft_datetime.strtodate(options.maxDate); to: maxDate = _xdsoft_datetime.strToDateTime(options.maxDate);

line 918: minDate = _xdsoft_datetime.strtodate(options.minDate); to: minDate = _xdsoft_datetime.strToDateTime(options.minDate);

pakoArtal avatar Jun 13 '14 10:06 pakoArtal

The fix by pakoArtal works for me when using the format of "d/m/Y h:i".

woanware avatar Jun 20 '14 08:06 woanware

Change: maxDate:jQuery('#date_end').val()?jQuery('#date_end').val():false to maxDate:jQuery('#date_end').val()?getDate(jQuery('#date_end').val()):false

and add the following function: function getDate(datum){ fn = datum.split("-"); return fn[0]+'/'+fn[1]+'/'+fn[2]; }

for german time (d.m.Y) use this function:

function getDate(datum){ fn = datum.split("."); return fn[2]+'/'+fn[1]+'/'+fn[0]; }

MDXDave avatar Jun 20 '14 13:06 MDXDave

I'm encountering this issue on v2.4.1. However, I'm using "m/d/Y" for the format. I've tried a couple of other formats, too, but the only one that works is "Y/m/d".

jasonmorehead avatar Mar 23 '15 15:03 jasonmorehead

something strange , but this is working for me. format: 'd/m/Y h:m', maxDate: '-1970/01/02',

bragg86 avatar May 13 '15 05:05 bragg86

Hey guys, Here is a way

jQuery(function() { jQuery('#datetimepicker1').datetimepicker({ format:'m/d/Y', onShow:function(ct){ this.setOptions({ maxDate:jQuery('#datetimepicker2').val()?jQuery('#datetimepicker2').val():false, formatDate:'m/d/Y', }); }, timepicker:false,

});

object90 avatar Oct 16 '15 08:10 object90

Hey ! Yes the solution of object90 is the right way because the default format is 'Y/m/d' so we have to set again the formatDate when we call the setOptions. It works for me !

korell avatar Apr 28 '16 16:04 korell

thank's... sangat membantu (indonesia).

imanismailbox avatar May 10 '16 03:05 imanismailbox

Thanks you

it worked

format: 'd/m/Y H:i', onShow: function (ct) { this.setOptions({ maxDate: $('#date_to').val() ? getDate($('#date_to').val()) : false, formatDate: 'd/m/Y', }) }, timepicker: true

and func function getDate(datum) { fn = datum.split(" "); fn0 = fn[0].split("/"); fn1 = fn[1].split(":"); return fn0[0] + '/' + fn0[1] + '/' + fn0[2]; }

ngnam avatar Apr 03 '17 02:04 ngnam

Hey guys, Here is a way

jQuery(function() { jQuery('#datetimepicker1').datetimepicker({ format:'m/d/Y', onShow:function(ct){ this.setOptions({ maxDate:jQuery('#datetimepicker2').val()?jQuery('#datetimepicker2').val():false, formatDate:'m/d/Y', }); }, timepicker:false,

});

Gracias :)

elAmado avatar Jul 16 '20 22:07 elAmado