{"action":"created","issue":{"url":"https://api.github.com/repos/moment/moment/issues/1407","labels_url":"https://api.github.com/repos/moment/moment/issues/1407/labels{/name}","comments_url":"https://api.github.com/repos/moment/moment/issues/1407/comments","events_url":"https://api.github.com/repos/moment/moment/issues/1407/events","html_url":"https://github.com/moment/moment/issues/1407","id":25343228,"number":1407,"title":"Be careful when falling back to Date constructor","user":{"login":"ichernev","id":757060,"avatar_url":"https://avatars.githubusercontent.com/u/757060?v=3","gravatar_id":"","url":"https://api.github.com/users/ichernev","html_url":"https://github.com/ichernev","followers_url":"https://api.github.com/users/ichernev/followers","following_url":"https://api.github.com/users/ichernev/following{/other_user}","gists_url":"https://api.github.com/users/ichernev/gists{/gist_id}","starred_url":"https://api.github.com/users/ichernev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ichernev/subscriptions","organizations_url":"https://api.github.com/users/ichernev/orgs","repos_url":"https://api.github.com/users/ichernev/repos","events_url":"https://api.github.com/users/ichernev/events{/privacy}","received_events_url":"https://api.github.com/users/ichernev/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/moment/moment/labels/Enhancement","name":"Enhancement","color":"fef2c0"},{"url":"https://api.github.com/repos/moment/moment/labels/todo","name":"todo","color":"5319e7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":125,"created_at":"2014-01-09T19:05:34Z","updated_at":"2015-10-27T09:02:07Z","closed_at":"2014-04-23T21:37:16Z","body":"If you clicked on the warning link and landed here:\r\n\r\n`moment` construction using a non-iso string is deprecated. What this means is you **can safely do**\r\n\r\n```javascript\r\n> moment(\"2014-04-25T01:32:21.196Z\");  // iso string, utc timezone\r\n> moment(\"2014-04-25T01:32:21.196+0600\");  // iso string with timezone\r\n> moment(\"2014 04 25\", \"YYYY MM DD\"); // string with format\r\n```\r\n\r\nbut you **can't do reliably** (therefore its being deprecated)\r\n\r\n```javascript\r\n> moment(\"2014/04/25\");\r\n> moment(\"Thu Apr 24 2014 12:32:21 GMT-0700 (PDT)\");\r\n> moment(\"some random string that looks like date\");\r\n```\r\n\r\nIn the upcoming releases a few more well defined formats might be added, but the general idea of using any random string to construct a date is no more. If you really want that behavior just do `moment(new Date(\"random string that contains date\"))`, but `moment` won't be responsible for such convertions. Read below for the rationale about the change\r\n\r\n==============\r\n\r\n\r\n\r\n\r\n\r\n\r\nAs described in https://github.com/moment/moment/issues/1403#issuecomment-31961590, but also recent debugging c4d9f6e and 94d6c90 caused by https://travis-ci.org/moment/moment/builds/16672288 brings me to the conclusion that \r\n\r\n> using `Date` to create a moment from string, passed from the user is extremely unpredictable, and it turns out to work somewhat and then bite you in an edge case when you're not careful\r\n\r\nSo I think we need an option to disable it, for tests at the very least. I've debugged that numerous times thank to our old friend IE6 and friends.\r\n\r\nYou'd pass a string only, hoping that it would hit one of the predefined formats, but instead it hits Date and it sort-of works, sometimes. I think it should be clear to users when they're hitting this case, and that it might not work well on all browsers.\r\n \r\nThe only use-case for using Date to parse input is when a) it is entered by a web user (moment's user's user :)) and b) the web user can see how we're interpreting the date entered. Every other case is just silently waiting to break at some point."},"comment":{"url":"https://api.github.com/repos/moment/moment/issues/comments/151419660","html_url":"https://github.com/moment/moment/issues/1407#issuecomment-151419660","issue_url":"https://api.github.com/repos/moment/moment/issues/1407","id":151419660,"user":{"login":"ipsita93","id":4394933,"avatar_url":"https://avatars.githubusercontent.com/u/4394933?v=3","gravatar_id":"","url":"https://api.github.com/users/ipsita93","html_url":"https://github.com/ipsita93","followers_url":"https://api.github.com/users/ipsita93/followers","following_url":"https://api.github.com/users/ipsita93/following{/other_user}","gists_url":"https://api.github.com/users/ipsita93/gists{/gist_id}","starred_url":"https://api.github.com/users/ipsita93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipsita93/subscriptions","organizations_url":"https://api.github.com/users/ipsita93/orgs","repos_url":"https://api.github.com/users/ipsita93/repos","events_url":"https://api.github.com/users/ipsita93/events{/privacy}","received_events_url":"https://api.github.com/users/ipsita93/received_events","type":"User","site_admin":false},"created_at":"2015-10-27T09:02:07Z","updated_at":"2015-10-27T09:02:07Z","body":"I get the same error as @imsobear. I am trying to convert from \"9:00 AM\" format to \"00:00:00\" format so I can store it as a TIME type in MySQL database. But how to do so?\r\n\r\n\r\nDeprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.\r\nError\r\n    at Function.createFromInputFallback (http://localhost:3000/javascripts/vendor/moment.js:746:36)\r\n    at configFromString (http://localhost:3000/javascripts/vendor/moment.js:826:32)\r\n    at configFromInput (http://localhost:3000/javascripts/vendor/moment.js:1353:13)\r\n    at prepareConfig (http://localhost:3000/javascripts/vendor/moment.js:1340:13)\r\n    at createFromConfig (http://localhost:3000/javascripts/vendor/moment.js:1307:44)\r\n    at createLocalOrUTC (http://localhost:3000/javascripts/vendor/moment.js:1385:16)\r\n    at local__createLocal (http://localhost:3000/javascripts/vendor/moment.js:1389:16)\r\n    at utils_hooks__hooks (http://localhost:3000/javascripts/vendor/moment.js:16:29)\r\n    at Object.$.validate.submitHandler (http://localhost:3000/javascripts/addstudentform.js:620:35)\r\n    at d (http://localhost:3000/javascripts/vendor/jquery.validate.min.js:4:885)\r\naddstudentform.js:621 Invalid date"}}