日期:2014-05-16  浏览次数:20316 次

js学习----datetime时间函数

JS操作日期function dateF(){?
var now = new Date();//当前日期?
var year = now.getYear();//年份后两位?
var fullYear = now.getFullYear();//获取完整的年份(4位,1970-????)?
now.getMonth();????? //获取当前月份(0-11,0代表1月)?
now.getDate();?????? //获取当前日(1-31)?
now.getDay();??????? //获取当前星期X(0-6,0代表星期天)?
now.getTime();?????? //获取当前时间(从1970.1.1开始的毫秒数)?
now.getHours();????? //获取当前小时数(0-23)?
now.getMinutes();??? //获取当前分钟数(0-59)?
now.getSeconds();??? //获取当前秒数(0-59)?
now.getMilliseconds();?? //获取当前毫秒数(0-999)?
now.toLocaleDateString();??? //获取当前日期?
var mytime=now.toLocaleTimeString();??? //获取当前时间?
now.toLocaleString( );?????? //获取日期与时间?

}?

获得日期星期与时间:?
setInterval("document.getElementById('linkweb').innerText=new Date().toLocaleString()+'星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);?
或是?
setInterval("document.getElementById('linkweb1').innerHTML=new Date().toLocaleSt