Timestamp:
1395660658
Code:
//timestamp conversion exports.getCurrentTimeFromStamp = function(timestamp) { var d = new Date(timestamp); timeStampCon = d.getDate() + '/' + (d.getMonth()) + '/' + d.getFullYear() + " " + d.getHours() + ':' + d.getMinutes(); return timeStampCon; };
This converts the time stamp properly in terms of time format, but the date is always:
17/0/1970
Why - cheers?
You have to multiply by 1000 as JavaScript counts in milliseconds since epoch (which is 01/01/1970), not seconds :
var d = new Date(timestamp*1000);
Reference
Because your time is in seconds. Javascript requires it to be in milliseconds since epoch. Multiply it by 1000 and it should be what you want.
//time in seconds var timeInSeconds = ~(new Date).getTime(); //invalid time console.log(new Date(timeInSeconds)); //valid time console.log(new Date(timeInSeconds*1000));