我是靠谱客的博主 淡定裙子,这篇文章主要介绍获取当前日期,时间,周数,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/** * description: 获取当前日期,时间,周数 * create_time: 2020-6-19 * function: getDate,getTime,getWeek */ class DateTime { // 构造方法 constructor() { // 列举Week this.weekday = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; // 获取当前时间 this.Date = new Date(); // 获取当前年 this.year = this.Date.getFullYear(); // 获取当前月 this.month = this.Date.getMonth() + 1; // 获取当前日 this.date = this.Date.getDate(); // 获取当前星期几 this.day = this.Date.getDay(); // 获取小时 this.hour = this.Date.getHours(); // 获取分钟 this.minute = this.Date.getMinutes(); // 获取秒 this.second = this.Date.getSeconds(); // 自动补零 this.month = (this.month < 10) ? '0' + this.month : this.month = this.month; this.date = (this.date < 10) ? '0' + this.date : this.date = this.date; this.minute = (this.minute < 10) ? '0' + this.minute : this.minute = this.minute; this.second = (this.second < 10) ? '0' + this.second : this.second = this.second; } /** * 取当前日期 * @returns {string} */ getDate() { return this.year + '-' + this.month + '-' + this.date; } /** * 获取当前时间 * @returns {string} */ getTime() { return this.hour + ':' + this.minute + ':' + this.second; } /** * 获取当前星期几 *@returns {string} */ getWeek() { return this.weekday[this.day] } } export { DateTime }

最后

以上就是淡定裙子最近收集整理的关于获取当前日期,时间,周数的全部内容,更多相关获取当前日期内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(46)

评论列表共有 0 条评论

立即
投稿
返回
顶部