使用javascript将datetime formate dd / mm / yyyy 12:14转换为dd / july / yyyy

时间:2015-07-30 09:54:58

标签: javascript

我想使用javascript将日期时间转换为dd/july/yyyy。 我有变量

var v = 29/09/2015 12:00  

并希望将其转换为29-july-2015

4 个答案:

答案 0 :(得分:1)

我假设您的var在引号中。



// note JS months are 0 based

var month = ["January","February","March","April","May","June","July","August","September","October","November","December"];

function conv(str) {
  var dateParts = str.split(" ")[0].split("/");
  return dateParts[0]+"-"+month[dateParts[1]-1]+"-"+dateParts[2];
}
  
alert(conv("29/09/2015 12:00"));




答案 1 :(得分:0)

你可以使用moment.js

来做到这一点

http://momentjs.com/

答案 2 :(得分:0)

使用momentjs.js,您可以通过以下代码实现此目的

var newDate = moment("29/01/2015 12:00" ,"DD-MM-YYYY").format('DD-MMM-YY');;

console.log(newDate);

答案 3 :(得分:-1)

//results in binary image
Imgproc.threshold(cropedIm,cropedIm,127,255,Imgproc.THRESH_BINARY);
//Inverting image
Core.bitwise_not(cropedIm, cropedIm);