javascript 获取javascript日期对象中的天数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6153688/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 19:41:12  来源:igfitidea点击:

get number of day in javascript date object

javascriptdateformatyahoo

提问by puchu

//27 <- today day number
new Date().getDay() = new Date().getUTCDay() //<- 5 (friday)? what?

Do I have to parse the result with .toString()or use something like YUI.Date.format()?

我是否必须解析结果.toString()或使用类似的东西YUI.Date.format()

回答by Andy E

You're looking for .getDate():

您正在寻找.getDate()

new Date().getDate();

.getDay()returns the day number 0 (Sunday) to 6 (Saturday).

.getDay()返回日期编号 0(星期日)到 6(星期六)。

回答by ShaneBlake

The one you are looking for is .getDate(), not .getDay()

你要找的是.getDate(), 不是.getDay()

Date Object Reference

日期对象参考

回答by J. Bruni

You should use

你应该使用

new Date().getDate()

回答by Reporter

getDay and getUTCDay returns the number of the weekday. You need getDate() and etUTCDate()

getDay 和 getUTCDay 返回工作日的编号。你需要 getDate() 和 etUTCDate()