Skip to content

Instantly share code, notes, and snippets.

@zhengfan2014
Created August 2, 2021 06:25
Show Gist options
  • Select an option

  • Save zhengfan2014/44a7ca947e5acfc61e4e6d3ab08b27f4 to your computer and use it in GitHub Desktop.

Select an option

Save zhengfan2014/44a7ca947e5acfc61e4e6d3ab08b27f4 to your computer and use it in GitHub Desktop.

Revisions

  1. zhengfan2014 created this gist Aug 2, 2021.
    12 changes: 12 additions & 0 deletions date.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    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;
    }