FYI: UNIX time or timestamp in ColdFusion

Discussion in 'Programming' started by garpenholm, Oct 11, 2007.

  1. #1
    UNIX time format in ColdFusion
    -----------------------------------------------------------------------
    I saw that this question was up in the PHP forum, so I also give an answer for ColdFusion:

    <CFSET unix_time = DateDiff("s", CreateDate(1970,1,1), Now()) />

    You need to change Now() to a ODBC DateTime variable like:

    <CFSET Your_Date = CreateDate (2006, 10, 05)>
    <CFSET Your_ODBCDate = CreateODBCDateTime(Your_Date)>
    <CFSET unix_time = DateDiff("s", CreateDate(1970,1,1), Your_ODBCDate) />
     
    garpenholm, Oct 11, 2007 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    garpenholm,

    Thanks for posting it. I was going to suggest you submit it to cflib.org, but just noticed they do have a similar function :)

    http://cflib.org/udf.cfm?ID=293
     
    cfStarlight, Oct 11, 2007 IP