How do I split the date and time into two elements?
Use date.toLocaleDateString()
for the date part, and date.toLocaleTimeString()
for the time part.
You can format your date using Date available methods:
var now = new Date()
var date = now.toLocaleDateString();
var time = now.toLocaleTimeString();
console.log(date + ' ' + time)