I have a JavaScript method which gets current date and returns its universal time. Below is the code:
function calUTCTime(offset) {
var currentDate = new Date();
var utc = currentDate.getTime() - (currentDate.getTimezoneOffset() * 60000);
var result = new Date(utc + (3600000 * offset));
return result .toLocaleString();
}
Above code is returning wrong date, it is replacing date with month and date format in my system is dd-MM-yyyy
, OS is Windows 8. I tried on other system's and the date is correct but on my system it is wrong. Please share suggestions.