So this works fine in Chrome, but not in IE (11) and Firefox
var startDate = moment("12-Nov-2015").format("D-MMM-YYYY"); var startTime = "10:00 AM"; var startDateTime = moment(startDate + ' ' + startTime); alert(moment(startDateTime).format("D-MMM-YYYY h:mm A"));
IE and Chrome just return "Invalid date"
any ideas that are missing?
This would be because "12-Nov-2015" is not a valid ISO 8601 format, so MomentJS is returning to the browser parser, which is different from the browser. Thus, this problem will be caused by the fact that Google Chrome accepts this format, but not IE or Firefox, and not a problem with Moment.
See this link for more details: http://momentjs.com/docs/#/parsing/string/
, ISO 8601 , http://momentjs.com/docs/#/parsing/string-format/
,
var startDate = moment("12-Nov-2015").format("D-MMM-YYYY");
var startDate = moment("12-Nov-2015", "D-MMM-YYYY").format("D-MMM-YYYY");
. : http://dygraphs.com/date-formats.html
Source: https://habr.com/ru/post/1616023/More articles:Держите show_compatibility_56 всегда включенным в MySQL - sqlPython How to generate random integers with multiple ranges? - pythonShould we use name functions in PHP? - functionQtWebEngine: "Не разрешено загружать локальный ресурс" для iframe, как отключить веб-безопасность? - javascriptundefined link to `libintl_gettext 'using MinGW / MSYS and CMake - c ++How to write a program for drawing a tiled image? - mathDifferent results with the same query in oracle 11g and 10g - oracleHow do I target :: before and :: after pseudo-elements in Internet Explorer 9 development tools? - htmlEnabling sticky session mode for load balancing Apache / Tomcat - tomcatNo HR username in Oracle 12c - oracleAll Articles