I have the following array:
1366004070000,1,1366004406000,1
The first and third entries are a unix timestamp. I need to convert this into a local datetime. How would I create a function to do this:
Here is what non-functional structure I have so far:
function toLocalTime(data) {
for (unixTime, successful in data) {
var d = new Date();
var tzOffset = d.getTimezoneOffset();
var new_time = unixTime - tzOffset
??
};
return newArray
}
I would like to produce an array of the same structure as the above, but with the timestamp converted to the localtime, something like:
1366004070444,1,1366004406444,1
Update: not one of the below answers gets the data in the format that I'm looking for. I am not looking for a local time object. I am looking for an array that gives me an "adjusted unix timestamp". In other words, the output should look indentical to the input, except for the slight adjustment in time from utc to localtime.