JS: new Date() is not accepting date string in my own locale (d/m/y)

前端 未结 3 1653
情深已故
情深已故 2020-12-11 01:34

My browser (ie. my OS) should know I\'m in Australia and what the correct date format is. In this case, d/m/y, not m/d/y. However if I run the following code:



        
3条回答
  •  盖世英雄少女心
    2020-12-11 02:21

    The Date object is very weak. You cannot tell it what format to expect. You can create it with a string in m/d/y like you stated, or new Date(year, month, day[, hours, seconds, milliseconds]);

提交回复
热议问题