Timestamp and time conversion

Convert timestamp to time:

$scope.getLocalTime = function (n) {
        return new Date(n).toLocaleDateString();
};

Convert time to timestamp:

var date = new Date(); // current time
console.log(date.getTime());
var d2 = new Date(2018,4,23);
console.log(d2.getTime());

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324743364&siteId=291194637