-1

regarding this link and info. :

How do I get a UTC Timestamp in JavaScript?

I could not post an update to the gentleman you gave me a hint at what could be done to enhance the answer:

I send thanks to : https://stackoverflow.com/users/376535/shiplu-mokadd-im shiplu.mokadd.im 29.1k33797

You could also do it utilizing getTimezoneOffset and getTime,

x = new Date()
var UTCseconds = (x.getTime() + x.getTimezoneOffset()*60*1000)/1000;

Thank you for the TIMEZONEOFFSET call. I made an enhancement.

 // 20140922 arf made another piece of server side classic asp work.

// I prefer moving both sides of equation to seconds.

x = new Date()
var UTCseconds = ( (x.getTime()/1000) + (x.getTimezoneOffset()/60) );
return UTCseconds

// sample from another post

<script language='Javascript' runat='server'>
   function jsGetUTCTime() {
    //var d = new Date();
    //return d.toUTCString();

    x = new Date()
    var UTCseconds = ( (x.getTime()/1000) + (x.getTimezoneOffset()/60) );
    return UTCseconds

  }
</script>
<script language='VBScript' runat='server'>
Function getUTCTime()
    ' Use JScript to get the current GMT time stamp
    getUTCTime = jsGetUTCTime()
End Function
</script>

< %
m_utc_time_stamp = getUTCTime()
% >
Community
  • 1
  • 1
  • Dates are already UTC timestamps in JS – dandavis Sep 23 '14 at 01:09
  • Thank Dan, http://www.w3schools.com/jsref/jsref_gettimezoneoffset.asp http://www.w3schools.com/jsref/jsref_gettime.asp did not seem so, but I needed that to to the HMAC-MD5 key, phrase translation in SHA1 format.. weird. – Andrew Flagg Sep 23 '14 at 01:13
  • 1
    Do you have a question here? – PM 77-1 Sep 23 '14 at 01:14
  • yeah, there's a function to get the offset, but if you do, say alert(+new Date()), you will see the UTC ms value, not the local ms value (unless you live in England). in short, you don't need to adjust the getTime() number to get UTC, doing so will actually adjust your date object to something other than UTC. – dandavis Sep 23 '14 at 01:16
  • really, no offset time zone adjustment required. i have been fighting with firstdata all day with their sha and md5 datetime seconds in utc from 1/1/70 and this is the only code that I have found to work, at least from the PST timezone, without have to hard code for a +7 hour offset and a soon +8 hour with daylight savings time. – Andrew Flagg Sep 23 '14 at 01:28
  • use that code and go here to compare http://www.mbari.org/staff/rich/utccalc.htm – Andrew Flagg Sep 23 '14 at 01:33
  • I think that this post is actually thanks to another post within SO, or possibly an attempt at an answer. – Paul Sep 23 '14 at 08:19

1 Answers1

0

I think you're looking for this:

UnixTimeStamp = DateDiff("s","01/01/1970",Now()) * 1000
Control Freak
  • 12,965
  • 30
  • 94
  • 145
  • i tried that and it did not even get close the right number FIRSTCARD was expecting from the server side. The result with that code was off by +7 hours. It needed to be adjusted based on GMT adjusting for timezone offset, ala the first post. – Andrew Flagg Sep 23 '14 at 14:49