-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
70 lines (62 loc) · 1.3 KB
/
test.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var moment = require('moment')
var js = {
"firstName": "Ben",
"birthdate": "1976-06-01T00:00:00.000+00:00",
"postalCode": "98103",
"gender": "Male",
"height": 1753,
"weight": 90718,
"preferredLocale": "en-US",
"lastUpdateTime": "2015-08-08T16:03:22.154+00:00"
};
console.log("Our date from the API call: " + js.birthdate);
console.log("Our converted date: " + MSHDateToTableauDate(js.birthdate));
console.log("Our date from the API call: " + js.lastUpdateTime);
console.log("Our converted date: " + MSHDateToTableauDate(js.lastUpdateTime));
// Use Moment to convert dates to acceptible format for Tableau
function MSHDateToTableauDate(dateToConvert) {
// Use moment
var moDate = moment(dateToConvert).format("YYYY-MM-DD HH:mm:ss.SSS");
return moDate;
}
/*
dd-MM-yyyy
dd-MMM
dd-MMM-yy
dd-MMM-yyyy
dd-MMM-yyyy HH:mm:ss
dd/MM/yyyy
h:mm a
HH.mm
hh.mm a
HH.mm.ss
hh.mm.ss a
hh:mm a
HH:mm:ss
hh:mma
M/d/yyyy HH:mm:ss
MM-dd-yyyy
MM-dd-yyyy HH:mm
MM/dd/yy
MM/dd/yy HH:mm:ss
MM/dd/yyyy
MM/dd/yyyy
MM/dd/yyyy HH:mm:ss
MM/dd/yyyy hh:mm:ss a
MMM yyyy
MMM-yy
MMMM dd yyyy
MMMM dd yyyy hh:mma
MMMM dd, yyyy
MMMM dd, yyyy HH:mm:ss
MMMM dd,yyyy
MMMM dd,yyyy HH:mm:ss
yyyy-MM-dd
yyyy-MM-dd HH:mm
yyyy-MM-dd HH:mm:ss
yyyy-MM-dd HH:mm:ss.SSS
yyyy-MM-dd HH:mm:ss.SSS
yyyy-MM-dd HH:mm:ss.SSS
yyyy/MM/dd
yyyy/MM/dd HH:mm:ss
*/