Authorize.net timestamp wrong due to Daylight Savings

I have an e-commerce site that uses Authorize.net SIM Gateway for processing credit cards.  A unique fingerprint is created for each transaction using a timestamp.  When daylight savings changed, it no longer matches authorize.net time stamp.  My host has verified the settings on the server and it still does not work, so I am forced to fix this within the code.

This is the current code that I am using for the timestamp:
<cfset timestamp=DateDiff("s", "January 1 1970 00:00", DateConvert('local2UTC', Now())) >

I have found other scripts, but they are even further off.

The timestamp can be checked by going to the following link:
http://developer.authorize.net/tools/responsecode97

Authorize.net says the following:
The transaction fingerprint depends on a timestamp expressed in POSIX Time, sometimes called UNIX Epoch Time. Simply put, it is the number of seconds since January 1, 1970, at Midnight UTC. If you take the current time in the server’s time zone and convert that to UTC, and then use that to calculate POSIX Time, that may introduce the risk of the time being miscalculated when the server switches from Standard Time to Daylight Savings Time. This will cause transaction fingerprints to fail.

To avoid this, we (authorize.net) recommend the following:

-Take care to use whatever options are available in your scripting language of choice to use POSIX time automatically, instead of trying to convert from local time to POSIX time. Most scripting languages support POSIX timestamps.
-Make sure the Web server is using UTC, not local time.
-The operating systems on Web servers should be kept up to date. Since Daylight Savings Time is defined by law and is subject to change, servers may need to be updated to reflect changes.
-Where possible, Web servers should use the Network Time Protocol (NTP) to keep their clocks synchronized.
lonnyoAsked:
Who is Participating?
 
_agx_Connect With a Mentor Commented:
No problem.  I may get caught with stuff this afternoon, but will try and check back later.

Small correction to the debug code above:

<cfoutput>
myTime  #now()#<br>
UTC Time #DateConvert('local2UTC', Now())#<br>
timestamp #DateDiff("s", "January 1 1970 00:00", DateConvert('local2UTC', Now()))#<br>
</cfoutput>

<cfdump var="#getTimeZoneInfo()#">
0
 
_agx_Commented:
> no longer matches authorize.net time stamp

I know you said the host check the settings, but without knowing more it does sounds like something on the server is off. How much is it off by? If it's about an hour, the DST settings on your server may be wrong.  For example, one of my test boxes was not set to DST time, so my timestamp was ~3660 seconds/1hr off from theirs

What are your timezone settings?

<cfoutput>
myTime  #now()#<br>
UTC Time #DateDiff("s", "January 1 1970 00:00", DateConvert('local2UTC', Now()))#<br>
</cfoutput>

<cfdump var="#getTimeZoneInfo()#">
0
 
lonnyoAuthor Commented:
Thanks for the quick responses.  I got pulled onto another project, so I will get back to this later today.  Sorry about that.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.