jquery獲取當前時間

2021-08-09 03:22:28 字數 672 閱讀 2517

一、獲取當前時間 new date()方法---------得到結果是當前電腦時間如2011-11-6,10:07

二、獲取有個固定的時間方法---------var endtime=new date("2013/10/01,18:25:00");

三、時間轉化成毫秒數----------endtime.gettime();

四、獲取當前的年份-----------endtime.getyear();

-----------endtime.getfullyear();

兩者的區別在於getyear不相容火狐瀏覽器,getfullyear相容好

五、獲取當前的月份---------endtime.getmonth();

六、獲取當前的日------getday

七、獲取小時--------gethours

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

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

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

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

例:

獲取當前時間

獲取日期 時間 datetime.now.tostring 2008 9 4 20 02 10 datetime.now.tolocaltime tostring 2008 9 4 20 12 12 獲取日期 datetime.now.tolongdatestring tostring 2008年9...

獲取當前時間

直接上可以執行的 檔案 獲取當前時間.cpp 方案 time 優點 僅使用c標準庫 缺點 只能精確到秒級 include time.h include stdio.h int main void 方案二getlocaltime 優點 能精確到毫秒級 缺點 使用了windows api include...

獲取當前時間

使用函式 date 實現 顯示的格式 年 月 日 小時 分鐘 妙 相關時間引數 a am 或是 pm a am 或是 pm d 幾日,二位數字,若不足二位則前面補零 如 01 至 31 d 星期幾,三個英文本母 如 fri f 月份,英文全名 如 january h 12 小時制的小時 如 01 至...