Created
August 2, 2021 06:25
-
-
Save zhengfan2014/44a7ca947e5acfc61e4e6d3ab08b27f4 to your computer and use it in GitHub Desktop.
时间戳转日期
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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