首页 > 代码库 > 字符串转日期

字符串转日期

function stringToDate(fDate){
  var fullDate = fDate.split(" ")[0].split("-");
  var fullTime = fDate.split(" ")[1].split(":");
  return new Date(fullDate[0], fullDate[1]-1, fullDate[2], (fullTime[0] != null ? fullTime[0] : 0), (fullTime[1] != null ? fullTime[1] : 0), (fullTime[2] != null ?     fullTime[2] : 0));
}