bootstrap-datepicker icon indicating copy to clipboard operation
bootstrap-datepicker copied to clipboard

How to get Multiple Dates in format YYYYMMDD?

Open alvin0618 opened this issue 11 years ago • 1 comments

Hi guys, I need helps on getting multiple dates format into 'yyyymmdd', I have no idea how to solve this.. Hope experts can help me !!! Thank you.

           $('#multiple-date-container').datepicker().on('changeDate', function(e){
                var dates = $('#multiple-date-container').datepicker('getDates');
                 console.log(dates);
                 $.each(dates, function(i, date){
                            var dpg = $.fn.datepicker.DPGlobal;
                            var date_format = 'dd/mm/yyyy';
                            var dd = dpg.formatDate(date, date_format, 'en');
                            console.log('date:'+JSON.stringify(date));
                            console.log('date.getDate():'+JSON.stringify(date.getDate()));
                            console.log(JSON.stringify(dd));
                });
            });
Result: ![multidate](https://cloud.githubusercontent.com/assets/8577299/7784456/ce46f79a-0198-11e5-90bf-73e931ba785e.png)

Wed May 13 2015 00:00:00 GMT+0800 (Malay Peninsula Standard Time),Sun May 10 2015 00:00:00 GMT+0800 (Malay Peninsula Standard Time) date:"2015-05-12T16:00:00.000Z" "12/05/2015" <<-------wrong date date:"2015-05-09T16:00:00.000Z" "09/05/2015" <<-------wrong date

alvin0618 avatar May 23 '15 14:05 alvin0618

try : moment(date).format('YYYY-MM-DD')

hfar avatar Jul 28 '15 13:07 hfar