码迷,mamicode.com
首页 > Web开发 > 详细

js 日期转字符串 时间类型转换

时间:2017-03-10 10:47:19      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:代码   raft   技术   字符串   nbsp   alt   img   split   date   

var draftTimeV = "Fri Mar 10 09:44:48 CST 2017";    <!--  示例 -->

  

  //核心代码---state

  draftTimeV = draftTimeV + "";
  var date = "";
  var month = new Array();
  month["Jan"] = 1; month["Feb"] = 2; month["Mar"] = 3; month["Apr"] = 4; month["May"] = 5; month["Jan"] = 6;
  month["Jul"] = 7; month["Aug"] = 8; month["Sep"] = 9; month["Oct"] = 10; month["Nov"] = 11; month["Dec"] = 12;

  str = draftTimeV.split(" ");
  date = str[5] + "-";
  date = date + month[str[1]] + "-" + str[2];

  //------end

  alert(date);

  效果:技术分享

 

  

//核心代码---state

  draftTimeV = draftTimeV + "";
  var date = "";
  var month = new Array();
  month["Jan"] = 1; month["Feb"] = 2; month["Mar"] = 3; month["Apr"] = 4; month["May"] = 5; month["Jan"] = 6;
  month["Jul"] = 7; month["Aug"] = 8; month["Sep"] = 9; month["Oct"] = 10; month["Nov"] = 11; month["Dec"] = 12;

  str = draftTimeV.split(" ");
  date = str[5] + "-";
  date = date + month[str[1]] + "-" + str[2]+" "+str[3];

  //------end

  效果:技术分享

js 日期转字符串 时间类型转换

标签:代码   raft   技术   字符串   nbsp   alt   img   split   date   

原文地址:http://www.cnblogs.com/licz/p/6529302.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!