Created
July 6, 2011 16:53
-
-
Save ciaranarcher/1067745 to your computer and use it in GitHub Desktop.
Function to Convert a ColdFusion Date to a .NET Ticks Representation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="getTicks" access="public" returntype="numeric" output="false" hint="Returns the number of .NET ticks representing a the given date."> | |
<cfargument name="dateValue" type="date" required="true" /> | |
<!--- | |
http://msdn.microsoft.com/en-us/library/system.datetime.ticks(v=vs.71).aspx | |
http://stackoverflow.com/questions/386341/c-how-do-i-convert-ticks-to-minutes | |
---> | |
<cfset var ticksAtEpochZero = 621355968000000000 /> <!--- Number of .NET ticks at Epoch time (January 1 1970 00:00) ---> | |
<cfset var ticksPerSec = 10000000 /> | |
<!--- Get difference between Epoch time and the given date expressed as ticks ---> | |
<cfset var ticksAtDate = dateDiff("s", "January 1 1970 00:00", ARGUMENTS.dateValue) * ticksPerSec /> | |
<!--- Add this to our baseline ticks value ---> | |
<cfset var ticks = (ticksAtEpochZero + ticksAtDate) /> | |
<cfreturn trim(numberFormat(ticks, "99999999999999999")) /> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment