Created
April 10, 2019 02:34
-
-
Save if540/b0effe2c405f11525176a2d25decf35f to your computer and use it in GitHub Desktop.
時間格式轉換
This file contains 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
// 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