How does safari convert the 2019-01-07T14:40:47.000+0000 type of time format?

Jun.15,2022

use moment


this is the standard ISO-8601 format.
just so new Date ("2019-01-07T14:40:47.000+0000") is fine.


Congratulations on stepping into an old pit. Safari does not support the format 2019-01-07 . You just need to replace - with / , that is, 2019-01-07 .


the simplest thing is to use moment.js or consider extracting the code from moment.js.
this is a bit crude, but simply extract the year, month, day, time, minute and second according to the position of T and then calculate the time difference

function formatUTC(t) {
  if(t.indexOf('T')!=-1){
     var y,h; //,
      var regH = /(T| )(\d\d:\d\d:\d\d)(\.\d+)?/;// 
      h = t.match(regH);
      h = h&&h[2]; //
      y = t.slice(0,t.indexOf('T')+1); //
      var timestamp = new Date(Date.parse(y.slice(0,-1)+' '+h)).getTime() / 1000;
      off = new Date().getTimezoneOffset() / 60; //
      timestamp -= off * 60 * 60;
     return new Date(parseInt(timestamp) * 1000);
  } 
 return new Date(t.replace(/\-/g,'/'));
}

formatUTC("2019-01-07T14:40:47.000+0000");
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ab37-34600.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ab37-34600.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?