javascript - moment.js gives invalid date in firefox, but not in chrome -


i'm having strange issue moment.js. wrote function convert time utc german time format, , seemed work fine in chrome. tried firefox , here got invalid date.

moment.locale("de");  $('#from').datepicker({     format: "dd. mmmm yyyy" });  $('#from').on('change',function() {      var = moment($('#from').val(), "dd. mmmm yyyy").format("llll");     var b = moment(a).add(7,'days');       var localtime  = moment.utc(b).todate();     localtime = moment(localtime).format('dd. mmmm yyyy');       $('#to').val(localtime);  });    $('#to').datepicker({     format:'dd.mmmm yyyy' });    $('#sendbtn').on('click',function(){      /...      var = moment(fromfield.value).format();      var = moment(tofield.value).format();       /...      $('#calendar').fullcalendar( 'gotodate', );     geteventdate(from,to,persons.value);       }  });   function geteventdate(start,end,people) {       var calendar = $('#calendar');      calendar.fullcalendar();      var event = {        title:"your stay "+people+" people",        allday: true,        start: start,        end: end       };       filljson(start,end,people);        calendar.fullcalendar( 'renderevent', event );   }     / ... 

i've seen answer can't work either way. can me out?

it's not clear question part of code throwing error, culprit moment.js delegates date.parse non-iso-8601 strings: https://github.com/moment/moment/issues/1407

so assuming you're using moment parse user input or field in unknown format, or parse format that's not iso-8601, you're going have specify format explicitly guaranteed cross-browser behavior. otherwise you're diving vaguaries of cross-browser date.parse - format works consistently there iso-8601.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -