JS中的日期方法有哪些

mac2025-12-09  1

JS中的日期方法

var times=new Date(); console.log(times); //获取日期对象中的年份 var year=times.getFullYear(); console.log(year); //获取日期对象中的月份 0-11 var month=times.getMonth()+1; console.log(month); //获取日期对象中的日 var day=times.getDate(); console.log(day); var hour=times.getHours(); console.log(hour); //获取日期对象中的分钟 var minute=times.getMinutes(); console.log(minute); //获取日期对象中的秒 var second=times.getSeconds();

到这里就没有了!

最新回复(0)