Avatar of roy_sanu
roy_sanu
Flag 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

JavaScriptjQueryScripting LanguagesNode.js

Avatar of undefined
Last Comment
Michael Vasilevsky

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Michael Vasilevsky

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes