0👍
✅
Here’s a way to manually mix them together…. The gist is to manually splice the strings together and then use Date.parse()
to make the date objects.
var dates = [
"2016-03-13",
"2016-03-13",
"2016-03-14",
"2016-03-14",
];
var times = [
"16:41:13",
"17:36:57",
"08:53:02",
"21:53:11",
];
var both = [];
for (var i = 0; i < dates.length; i++) {
both.push(new Date(Date.parse(dates[i] + " " + times[i])));
}
console.log("%j",both);
0👍
0👍
try splitting the dates and times with ,
and concat each of them by using loop
var data = {
"dates": [
"2016-03-13",
"2016-03-13",
"2016-03-14",
"2016-03-14"
],
"times": [
"16:41:13",
"17:36:57",
"08:53:02",
"21:53:11"
]
}
var datetimes = [];
for (var i = 0; i < data.dates.length; i++) {
datetimes.push(data.dates[i] + ' ' + data.times[i]);
}
document.write('<pre>' + JSON.stringify(datetimes, 0, 4) + '</pre>')
Source:stackexchange.com