i need javascript code to capture currentdate and time into custom date and time field , here i am using onsave event i am passing the currentdate and current time to custom field. Below code is returning null value
function updateCurrentDate() {
var currentDate = new Date();
var day = currentDate.getDate()
var month = currentDate.getMonth() + 1
var year = currentDate.getFullYear()
var currentDate = month + "/" + day + "/" + year;
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
var seconds = currentTime.getSeconds()
if (hours <12)
var suffix = "AM";
if (hours >= 12)
var suffix = "PM";
var currentTime = hours+":"+minutes+":"+seconds+" "+suffix;
var currentDateTime = currentDate +' '+currentTime ;
if (currentDateTime != null) {
Xrm.Page.getAttribute("date_A").setValue(currentDateTime );
}
}
*This post is locked for comments