js日期函数

来源:互联网 发布:淘宝怎么限制买家购买 编辑:程序博客网 时间:2024/05/22 12:05

js日期函数

以下是搜到的有用内容(以备查阅):

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

0 0
原创粉丝点击