![](/img/trans.png)
[英]How do I calculate the date in JavaScript, to get the same day in month + some month (variable)
[英]How do I get the day of the month in javascript?
我需要从 Date 对象获取月份中的哪一天,但似乎getDay()
方法返回了星期几。 是否有返回月份中日期的函数?
尝试使用getDate()代替。 令人困惑的命名,但这就是生活......
var date = new Date().getDate();
const date = new Date();
const day = date.getDate();
const month = date.getMonth() + 1;
const year = date.getFullYear();
.getDate()
是您要在日期对象上调用的方法。 如文档中所示:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.