JavaScript獲取當前系統時間

2021-07-02 06:39:06 字數 698 閱讀 3418

var mydate = new date();

mydate.getyear();        //獲取當前年份(2位)

mydate.getfullyear();    //獲取完整的年份(4位,1970-????)

mydate.getmonth();       //獲取當前月份(0-11,0代表1月)

mydate.getdate();        //獲取當前日(1-31)

mydate.getday();         //獲取當前星期x(0-6,0代表星期天)

mydate.gettime();        //獲取當前時間(從1970.1.1開始的毫秒數)

mydate.gethours();       //獲取當前小時數(0-23)

mydate.getminutes();     //獲取當前分鐘數(0-59)

mydate.getseconds();     //獲取當前秒數(0-59)

mydate.getmilliseconds();    //獲取當前毫秒數(0-999)

mydate.tolocaledatestring();     //獲取當前日期

var mytime=mydate.tolocaletimestring();     //獲取當前時間

mydate.tolocalestring( );        //獲取日期與時間

JavaScript獲取當前根目錄

主要用到location 物件,包含有關當前 url 的資訊,是 window 物件的乙個部分,可通過 window.location 屬性來訪問。方法一 window.document.location.href window.document.location.pathname 網路 funct...

JavaScript獲取當前根目錄

主要用到location 物件,包含有關當前 url 的資訊,是 window 物件的乙個部分,可通過 window.location 屬性來訪問。方法一 window.document.location.href window.document.location.pathname 網路 funct...

JavaScript獲取當前日期時間

獲取當前日期時間 獲取當前日期時間 var mydate newdate mydate.tolocaledatestring 獲取當前日期 var mytime mydate.tolocaletimestring 獲取當前時間 mydate.tolocalestring 獲取日期與時間 mydate...