我想使用javascript将日期时间转换为dd/july/yyyy
。
我有变量
var v = 29/09/2015 12:00
并希望将其转换为29-july-2015
。
答案 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
来做到这一点答案 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);