uniapp's new Date () time problem

Problem:
When uniapp uses new Date().toISOString().slice(11, 19) to get the hour, minute and second, 8 hours are missing.

Solution:

var tzoffset =(new Date()).getTimezoneOffset()* 60000; //以毫秒为单位的偏移
var localISOTime =(new Date(Date.now() -  tzoffset)).toISOString().slice(11,19);

(new Date()).getTimezoneOffset(), the return value unit of this method is minutes! !
The -480 I got here happened to be 8 hours less.

Guess you like

Origin blog.csdn.net/babdpfi/article/details/118193522