-
-
Save Eden-Harris/6f79aed0ebf040c76b6c89f607b09de0 to your computer and use it in GitHub Desktop.
😋 js 时间格式化 date format YYYY-mm-dd HH:MM:SS
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
// 😋 js 时间格式化 date format YYYY-mm-dd HH:MM:SS | |
const ISO = (timeStamp=Date.now()) => { | |
return new Date(timeStamp - (new Date().getTimezoneOffset() * 60 * 1000)).toISOString().slice(0,-5).split('T') | |
} | |
console.log('one->',ISO(new Date('2020-09-26 11:28:55').getTime())) | |
console.log('now->',ISO()) | |
// one-> [ '2020-09-26', '11:28:55' ] | |
// now-> [ '2021-09-26', '20:13:36' ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment