如何使用 JavaScript 向日期中添加多个月?
若要向日期中添加多个月,首先使用 getMonth() 方法获取月份,然后添加多个月。
示例
你可以尝试运行以下代码以添加多个月
<!DOCTYPE html>
<html>
<body>
<script>
var d, e;
d = new Date();
document.write(d);
e = d.getMonth()+1;
document.write("<br>Incremented month = "+e);
</script>
</body>
</html>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
安卓
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP