UTC时间转换为本地时间格式

参考一:

new Date('2018-08-06T10:00:00.000Z').toLocaleString().replace('上午', 'AM 0').replace('下午', 'PM 0').replace(/\//g, '-')

参考二:Java方法:

package jp.misumi.wos.components.service.hp;
 
import java.text.SimpleDateFormat;
import java.util.Date;
 
public class Test {
    public static void main(String[] args) {
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
        try {
              Date date = sdf1.parse("2018-01-22T09:12:43.083Z");//拿到Date对象
              String str = sdf2.format(date);//输出格式:2017-01-22 09:28:33
              System.out.println(str);
          } catch (Exception e) {
              e.printStackTrace();
          }
    }
}

参考三:

myFunction();
       function myFunction(){
           
           var dateee = new Date("2018-05-19T00:00:00.000+0000").toJSON();

//        var dateee = new Date("2017-07-09T09:46:49.667").toJSON();
        
        var date = new Date(+new Date(dateee)+8*3600*1000).toISOString().replace(/T/g,' ').replace(/\.[\d]{3}Z/,'')  
        
           alert(date);
           console.log("时间2==="+date);

}
 

参考四:

UTC时间转换为本地时间格式_第1张图片

参考五:

UTC时间转换为本地时间格式_第2张图片

你可能感兴趣的:(前端环境)