Topic: Display date and time using JavaScript
Well, seems like this board have been dead for quite a long time. So, thought of reviving it up with few worthwhile discussions. This is a start.
(function() {
var oDate = new Date();
var date = oDate.getDate();
var mnth = oDate.getMonth();
var year = oDate.getFullYear();
var hrs = oDate.getHours();
var min = oDate.getMinutes();
console.log('Date: ' + date + '/' + mnth + '/' + year);
console.log('Time: ' + hrs + ':' + min);
})();
So, this is the code to display date and time using Javascript.
Note that I am using Nodejs, and so using console.log to display output.
The topic introduces useage of Date object to display current date and time based on users system.
The topic also introduces closures, a really interesting feature in javascript.
More details on Date object from MDN https://developer.mozilla.org/en/docs/J … jects/Date