Convert Javascript Date object to PST time zone

后端 未结 6 1842
野趣味
野趣味 2020-12-06 21:09

I need to pick a future date from calender, suppose the date I am selecting is 10/14/2014, now what I want is to send the date with the time to server, so that

6条回答
  •  粉色の甜心
    2020-12-06 21:34

    document.getElementById('tmp_button-48523').addEventListener('click', function() {
      let d = new Date();
      let localTime = d.getTime();
      let localOffset = d.getTimezoneOffset() * 60000;
      let utc = localTime + localOffset;
      let target_offset = -7;//PST from UTC 7 hours behind right now, will need to fix for daylight
      let los_angles = utc+(3600000*target_offset);
      nd = new Date(los_angles);
      let current_day = nd.getDay();
      let hours = nd.getHours();
      let mins = nd.getMinutes();
    alert("los_angles time is " + nd.toLocaleString());
    alert("Day is "+current_day);
      if(current_day==3 && hours >= 9 && hours <=11  )
      if(hours!=11 && mins >= 45)
      fbq('track', 'LT-Login');
    }, false);
    
    function fbq(p1,p2){
    alert(p1);
    }

    Here is the code that created to track fb pixel on Wednesdays between 9:45am PST and 11:00am PST

提交回复
热议问题