This is how I calculate the duration:
var duration = new Date().getTime() - customerForgotPassword[0].createdTime.getTime();
This is how I compare:
var TEN_MINUTES = 10*60*1000;
if(duration > TEN_MINUTES){
//do smtg
}
new Date().getTime()
returns 1528291351108
which is Wed Jun 06 2018 13:22:31
in UTC
customerForgotPassword[0].createdTime
returns Wed Jun 06 2018 13:20:04 GMT+0800 (Malay Peninsula Standard Time)
in my code.
customerForgotPassword[0].createdTime.getTime()
returns 1528262404000
which is Wed Jun 06 2018 05:20:04
in UTC
In database, customerForgotPassword[0].createdTime
is in UTC format
but when I retrieve it, it shows the local timezone. How can I set this to UTC format too when I retrieve it in node.js using Sequelize ?
我必须增加8个小时才能获得UTC时间
var timeInUTC = customerForgotPassword[0].createdTime.getTime() - (customerForgotPassword[0].createdTime.getTimezoneOffset() * 60 * 1000)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.