-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
36 lines (32 loc) · 905 Bytes
/
utils.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
34
35
36
function formatDate(dateString) {
const date = new Date(dateString);
const months = [
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December",
];
let outString = "";
const month = months[date.getUTCMonth()];
const day = date.getUTCDate();
const year = date.getUTCFullYear();
const hour = date.getUTCHours();
const minute = date.getUTCMinutes();
outString += month + " " + day;
switch (day % 10) {
case 1:
outString += "st";
break;
case 2:
outString += "nd";
break;
case 3:
outString += "rd";
break;
default:
outString += "th";
break;
}
outString += " " + year + " at ";
outString += hour + ":";
outString += (minute < 10 ? "0" : "") + minute;
return outString;
}