I have unix TimeStamp value which is in UTC . I want to convert that timestamp into local date and time with timezone.
By using the following code, I am manged to covert to UTC date and time
function convertTimestamp(timestamp) {
var d = new Date(timestamp * 1000),
yyyy = d.getFullYear(),
mm = ('0' + (d.getMonth() + 1)).slice(-2),
dd = ('0' + d.getDate()).slice(-2),
hh = d.getHours(),
h = hh,
min = ('0' + d.getMinutes()).slice(-2),
time;
time = yyyy + '-' + mm + '-' + dd + ', ' + h + ':' + min + ' ';
return time;
}
Example:
3680283088 => 05/10/2017 13:46:49 EDT
Please recommend the right way to convert UTC timestamp to local date and time with timezone.