1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | const monthNames = [
|
19 | 'Jan',
|
20 | 'Feb',
|
21 | 'Mar',
|
22 | 'Apr',
|
23 | 'May',
|
24 | 'Jun',
|
25 | 'Jul',
|
26 | 'Aug',
|
27 | 'Sep',
|
28 | 'Oct',
|
29 | 'Nov',
|
30 | 'Dec',
|
31 | ];
|
32 | const weekNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
33 |
|
34 |
|
35 | export default class DateHelper {
|
36 | |
37 |
|
38 |
|
39 | getNowString() {
|
40 | const now = new Date();
|
41 |
|
42 | const weekDay = weekNames[now.getUTCDay()];
|
43 | const month = monthNames[now.getUTCMonth()];
|
44 | const day = now.getUTCDate();
|
45 |
|
46 | let hours = now.getUTCHours();
|
47 | if (hours < 10) {
|
48 | hours = `0${hours}`;
|
49 | }
|
50 |
|
51 | let minutes = now.getUTCMinutes();
|
52 | if (minutes < 10) {
|
53 | minutes = `0${minutes}`;
|
54 | }
|
55 |
|
56 | let seconds = now.getUTCSeconds();
|
57 | if (seconds < 10) {
|
58 | seconds = `0${seconds}`;
|
59 | }
|
60 |
|
61 | const year = now.getUTCFullYear();
|
62 |
|
63 |
|
64 | const dateNow = `${weekDay} ${month} ${day} ${hours}:${minutes}:${seconds} UTC ${year}`;
|
65 |
|
66 | return dateNow;
|
67 | }
|
68 | }
|