设置时间日期
通过时间日期对象,可以将其中的年月日时分秒进行设置,改变时间日期对象的时间。
date.setFullYear(年份); // 设置时间日期对象中的年份 date.setMonth(当前月份-1); // 设置时间日期对象中的月份 - 这里的月份是通过0~11来描述1~12月的 date.setDate(日); // 设置时间日期对象中的日 date.setHours(时); // 设置时间日期对象中的时 date.setMinutes(分); // 设置时间日期对象中分 date.setSeconds(秒); // 设置时间日期对象中的秒 date.setMilliseconds(毫秒); // 设置时间日期对象中的毫秒 date.setTime(时间戳); // 设置时间日期对象对应的时间戳 - 直接用时间戳就能将时间日期对象中的年月日时分秒全部改变