千鋒教育JavaScript全套視頻教程(10天學(xué)會(huì)Js,前端javascrip
2023-07-17 16:18 作者:bili_65370453152 | 我要投稿

P64 時(shí)間對(duì)象
創(chuàng)建時(shí)間對(duì)象:var date = new Date();
獲取年:date.getFullYear();
獲取月:date.getMonth();//0-11表示1-12月
獲取日:date.getDate();
獲取周:date.getDay();//周日是0,周一-周六 1-6
獲取時(shí):date.getHours();
獲取分:date.getMinutes();
獲取秒:date.getSeconds();
獲取毫秒:date.getMilliseconds();
獲取事件戳:date.getTime();//距離1970年1月1號(hào)0點(diǎn)0分0秒的毫秒數(shù)
//設(shè)置
設(shè)置年:date.setFullYear();
設(shè)置月:date.setMonth();//0-11表示1-12月
設(shè)置日:date.setDate();
設(shè)置時(shí):date.setHours();
設(shè)置分:date.setMinutes();
設(shè)置秒:date.setSeconds();
設(shè)置事件戳:date.setetTime();
標(biāo)簽: