js面向对象学习笔记之四(Date 对象)

时间:2015-04-28 18:34:00   收藏:0   阅读:306
//日期字符串转时间戳
  var date="2015-03-18";
  date = new Date(Date.parse(date.replace(/-/g, "/")));
  date = date.getTime();
  document.write(date);

  var date = new Date(); //返回当前的时间对象
  getDate() 	   //日    从 Date 对象返回一个月中的某一天 (1 ~ 31)。
  getDay() 	       //星期  从 Date 对象返回一周中的某一天 (0 ~ 6)。
  getMonth() 	   //月    从 Date 对象返回月份 (0 ~ 11)。 需要加 1
  getFullYear()    //年    从 Date 对象以四位数字返回年份。
  getHours() 	   //时    返回 Date 对象的小时 (0 ~ 23)。
  getMinutes() 	   //分    返回 Date 对象的分钟 (0 ~ 59)。
  getSeconds()     //秒	   返回 Date 对象的秒数 (0 ~ 59)。

原文:http://blog.csdn.net/wujiangwei567/article/details/45337689

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!