Hi Yin,
function getCurrentDateTime() {
return new Date();
}
function setCurrentDateTimeToObjectField(myObject, attributeName) {
var currentDate = getCurrentDateTime();
myObject.setAttribute(attributeName, currentDate);
}
Let me know, if you have any issues,
Hope it helps!!