js动态获取实时时间

给大家整理了一点获取当下实时时间的方法:

            let curDate = new Date(); //获取对象
            
            let year = curDate.getFullYear();        //获取年
            
            let curMonth = curDate.getMonth() + 1;  //获取当前月份(0-11,0代表1月)
            
            let curDay = curDate.getDate();       //获取当前日(1-31)
            
            let curWeekDay = curDate.getDay();    //获取当前星期X(0-6,0代表星期天)
            
            let curHour = curDate.getHours();      //获取当前小时数(0-23)
            
            let curMinute = curDate.getMinutes();   // 获取当前分钟数(0-59)
            
            let curSec = curDate.getSeconds();      //获取当前秒数(0-59)

猜你喜欢

转载自blog.csdn.net/qq_60961397/article/details/121148815