Home > Software engineering >  ColdFusion : CreateDateTime : 13 digit epoch time
ColdFusion : CreateDateTime : 13 digit epoch time

Time:02-19

Is there an easy way to create ColdFusion now() into a 13 digit UTC Epoch Time

I found this code... But it shows a -1343911774836 I know I can force positive, but I don't even know if the conversion is correct.

<cfset startDate = createdatetime(#now()#)> 
<cfset datetimeNow = dateConvert( "local2Utc", now() )>
<cfset UnixStamp = datediff( 's', startdate, datetimeNow )>
<b>#unixstamp#</b>

This works from RRK Comments

      <cfset startDate = now()> 
      <cfset datetimeNow = dateConvert( "local2Utc", now() )>
      <cfoutput>
        <b>#now().getTime()#</b>
        <b>#datetimeNow.getTime()#</b>
      </cfoutput>

CodePudding user response:

You can use the java getTime() method linked to data variables in Coldfusion.

now().getTime()

Example

  • Related