LoginSignup
0
0

More than 5 years have passed since last update.

JS 文字列をDateへ変換

Last updated at Posted at 2018-11-29

IEで直入れ上手くいかなかったので
文字列をバラして、単品づつDateに渡す方式

toDate
toDate: function (s) {
  if (0 < s.length) {
    var result = s.split(" ");
    var date = result[0].trim().split("/");
    var time = result[1].trim().split(":");
    return new Date(
      parseInt(date[0], 10),
      parseInt(date[1], 10) - 1,
      parseInt(date[2], 10),
      parseInt(time[0], 10),
      parseInt(time[1], 10));
  }
},
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0