javascript 日期操作

1.javascript中日期的构造函数:

new Date("month dd,yyyy hh:mm:ss");
new Date("month dd,yyyy");
new Date(yyyy,mth,dd,hh,mm,ss);
new Date(yyyy,mth,dd);
new Date(ms);

2.测试:

 	document.write("
" + new Date("February 3,2009")); document.write("
" + new Date("February 3,2009 10:52:03")); document.write("
"); document.write("
" + new Date(2009,1,3)); document.write("
" + new Date(2009,1,3,10,52,03)); document.write("
"); document.write("
" + new Date(Date.parse("February 3,2009"))); document.write("
" + new Date(Date.parse("February 3,2009 10:52:03"))); document.write("
" + new Date(Date.parse(2009,1,3))); document.write("
" + new Date(Date.parse(2009,1,3,10,52,03))); document.write("
" + new Date(Date.parse("2009/02/03"))); document.write("
"); document.write("
" + new Date("2009/02/03")); document.write("
" + new Date("2009/02/03 11:12:13")); document.write("
" + new Date("2009-02-03")); document.write("
"); document.write("
" + new Date("2009-02-03")); document.write("
" + new Date("2009-02"));

你可能感兴趣的:(11_js)