Skip to content

Instantly share code, notes, and snippets.

@zhengfan2014
Created August 2, 2021 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhengfan2014/44a7ca947e5acfc61e4e6d3ab08b27f4 to your computer and use it in GitHub Desktop.
Save zhengfan2014/44a7ca947e5acfc61e4e6d3ab08b27f4 to your computer and use it in GitHub Desktop.
时间戳转日期
Timestamp2Date: function(time) {
if (time != null) {
var date = new Date(time * 1000);
Y = date.getFullYear() + '-';
M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
time = Y + M + D + h + m
}
return time;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment