码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript内置对象Date常用函数

时间:2018-07-16 23:06:14      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:格式   javascrip   字符   value   led   日期   字符串   script   EDA   

//        //获取当前时间
// var dt = new Date();
// alert(dt);
// //传入时间
// var dt1 = new Date("2017-08-12");
// alert(dt1);
//
// //获取时间的对象(毫秒)
// var dt2 = Date.now();
// alert(dt2);
//
// var dt3 = new Date();
// //获取年份
// alert(dt3.getFullYear());
// //获取月份
// alert(dt3.getMonth() + 1);//是从0开始真实月份需要加1
// //获取日期
// alert(dt3.getDate());
// //获取小时
// alert(dt3.getHours());
// //获取分钟
// alert(dt3.getMinutes());
// //获取秒
// alert(dt3.getSeconds());
// //获取星期
// alert(dt3.getDay());

var dt = new Date();
alert(dt.toDateString());//英文的--日期
alert(dt.toLocaleDateString());//数字格式--日期
alert(dt.toTimeString());//小时,分钟,秒
alert(dt.toLocaleTimeString());//小时,分钟,秒
alert(dt.valueOf());//获取时间的毫秒值
alert(dt);
//转换成字符串
alert(dt.toString());

JavaScript内置对象Date常用函数

标签:格式   javascrip   字符   value   led   日期   字符串   script   EDA   

原文地址:https://www.cnblogs.com/cuilichao/p/9320712.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!