As toISOString()
will only return current UTC time , not local time. We have to make a date by using '.toString()' function to get date in yyyy-MM-dd
format like
document.write(new Date(new Date().toString().split('GMT')[0]+' UTC').toISOString().split('T')[0]);
To get date and time into in yyyy-MM-ddTHH:mm:ss
format
document.write(new Date(new Date().toString().split('GMT')[0]+' UTC').toISOString().split('.')[0]);
To get date and time into in yyyy-MM-dd HH:mm:ss
format
document.write(new Date(new Date().toString().split('GMT')[0]+' UTC').toISOString().split('.')[0].replace('T',' '));