-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdate.js
33 lines (29 loc) · 847 Bytes
/
date.js
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
module.exports = {currentDate,DMY};
function currentDate() {
let today = new Date(),
day = today.getDate(),
month = today.getMonth() + 1, //January is 0
year = today.getFullYear();
if (day < 10) {
day = '0' + day
}
if (month < 10) {
month = '0' + month
}
today = year + '-' + month + '-' + day;
return today;
}
function DMY() {
var year, month, day;
var monthShortNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
year = String(this.getFullYear());
month = String(this.getMonth());
// if (month.length == 1) {
// month = "0" + month;
// }
day = String(this.getDate());
if (day.length == 1) {
day = "0" + day;
}
return day + " " + monthShortNames[month] + " " + year;
};