Skip to content

Instantly share code, notes, and snippets.

@if540
Created April 10, 2019 02:34
Show Gist options
  • Save if540/b0effe2c405f11525176a2d25decf35f to your computer and use it in GitHub Desktop.
Save if540/b0effe2c405f11525176a2d25decf35f to your computer and use it in GitHub Desktop.
時間格式轉換
// 1554863406354 to Wed Apr 10 2019 10:29:26 GMT+0800 (台北標準時間)
function toUTC (value) {
var date = new Date()
if (value) {
date = new Date(value)
}
var nowUtc = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(),
date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds())
return nowUtc
}
// use: new Date(toUTC());
//源至: https://stackoverflow.com/questions/948532/how-do-you-convert-a-javascript-date-to-utc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment