This tutorial will help you to get current date and time at which the function is executed. Here is the function:
var currentdate = new Date();
var time=currentdate.getFullYear()+”-“+(currentdate.getMonth()+1)+”-“+currentdate.getDate()+” “+currentdate.getHours()+”:”+currentdate.getMinutes()+”:”+currentdate.getSeconds();
Just print out ctime() function to get the date and time in the format YEAR/MONTH/DAY HOUR:MINUTE:SECOND
new Date() function prints out the current date and time in a disorderly way. You can order it in any way as I did in the time() function.
currentdate.getFullYear() will get the year from new Date() which is in the variable currentdate
currentdate.getDate() will get the day of the month in which the function is executed.
currentdate.getHours() will give the Hour of the time.
currentdate.getMinutes() will give the Minute in which the script is executed.
currentdate.getSeconds() This function will give the seconds of the time at which the script is executed.