Skip to content

Instantly share code, notes, and snippets.

@Eden-Harris
Last active September 26, 2021 12:32
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 Eden-Harris/6f79aed0ebf040c76b6c89f607b09de0 to your computer and use it in GitHub Desktop.
Save Eden-Harris/6f79aed0ebf040c76b6c89f607b09de0 to your computer and use it in GitHub Desktop.
😋 js 时间格式化 date format YYYY-mm-dd HH:MM:SS
// 😋 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