如题,怎么获取。
2 回答
已采纳

慕莱坞9220042
TA贡献377条经验 获得超508个赞
你好,有两种办法;
1、获取日期后用分割函数分割开;
2、直接获取:
var now = new Date(); //当前日期 var nowDayOfWeek = now.getDay(); //今天本周的第几天 var nowDay = now.getDate(); //当前日 var nowMonth = now.getMonth(); //当前月 var nowYear = now.getFullYear(); //当前年
望采纳!

super_mb
TA贡献101条经验 获得超107个赞
var date = new Date(); //Date 对象自动使用当前的日期和时间作为其初始值。 var year = date.getFullYear(); //从date对象获取当前年 var month = date.getMonth() + 1; //用getMonth()获得的月份从0~11,所以要获得当前月份,需要加1 var day = date.getDate(); //获取当前日
添加回答
举报
0/150
提交
取消