Link to home
Start Free TrialLog in
Avatar of roy_sanu
roy_sanuFlag for India

asked on

Review of the nodejs code

Hello expert,

 I have a piece of code which i used it in other, is it a correct way of doing it or any other way we can have


function addZero(i) {
	if (i < 10) {
		i = "0" + i;
	}
	return i.toString();
}

Open in new window


//---  create current date in YYYY-MM-DD HH:MM:SS format ---//
function curDate() {
	var d = new Date();
	var crDate = d.getFullYear()
	+ '-' + addZero(d.getMonth() + 1)
	+ '-' + addZero(d.getDate())
	+ ' ' + addZero(d.getHours())
	+ ':' + addZero(d.getMinutes())
	+ ':' + addZero(d.getSeconds());
	return crDate;
}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Michael Vasilevsky
Michael Vasilevsky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial