1 Star 0 Fork 0

math.most/js_study

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
013Date对象.js 863 Bytes
一键复制 编辑 原始数据 按行查看 历史
Administrator 提交于 2021-05-05 20:31 +08:00 . 第一次学习的笔记代码
/**
* Date对象
*/
// 创建时间处理对象
var date = new Date();
// 返回当前时间
console.log(date); // 2020-05-05T11:54:49.275Z
// 获取当前对象的时间戳,从1970年1月1日0:0:0到当前日期花费的'毫秒数'
console.log(date.getTime()); // 1520216319647
// 获取当前的时间戳
console.log(Date.now()); // 1520216602433
// 获取当前对象是几日,如今天为5月5日,则返回5
console.log(date.getDate()); // 5
// 获取当前日期为周几: 0表周日 1表示周一 ... 6表示周六
console.log(date.getDay()); // 3
// 获取当前月份0-11的值
console.log(date.getMonth()); // 4
// 获取当前年份
console.log(date.getFullYear()); // 2020
// 获取当前小时、分钟、秒数...
console.log(date.getHours()); // 2020
console.log(date.getMinutes()); // 4
console.log(date.getMilliseconds()); // 595
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mathmost/js_study.git
git@gitee.com:mathmost/js_study.git
mathmost
js_study
js_study
master

搜索帮助