javascript中的当前日期

时间:2015-10-31 14:58:54

标签: javascript jquery date

如何将当前日期显示在jquery中作为“2015年10月31日星期六”?我只能找到如何让日期显示为“dd / mm / yyyy”

3 个答案:

答案 0 :(得分:2)

要获得 2015年10月31日,请使用:

// "31/10/2015" and august : 31/08/2015 :
var a=new Date();
alert([("0" + a.getDate()).slice(-2), ("0" + (a.getMonth()+1)).slice(-2), a.getFullYear()].join("/"));

// "31/10/2015" and august : 31/8/2015 :
[a.getDate(), (a.getMonth() + 1), a.getFullYear()].join("/"); 

示例:

function getDate() {
  var a=new Date();
  return [("0" + a.getDate()).slice(-2), ("0" + (a.getMonth() + 1)).slice(-2), a.getFullYear()].join("/");
}


document.write(getDate());

答案 1 :(得分:1)

要获得2015年10月31日星期六,请使用:

area()

JsFiddle

答案 2 :(得分:1)

你可以:

Sunday, November 1, 2015
  

if(sum.toString().length == 1)