House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

ColdFusion and Unix Timestamps

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jon Clausen
05/02/2007 02:32 PM

So I'm working on some code to interface with a webservice using PHP   and they require that a UNIX (Epoch)  timestamp  be passed to   retrieve data which has been modified from that date.   No problem.   I use something like the following to generate the timestamp: <cfset date = dateAdd("d",-1, now())> <cfset date = createODBCDateTime(date)> <cfset udate = date.getTime()> Unfortunately that generates a 64-bit timestamp, which I found trying   to validate the date  at http://www.unixtimestamp.com/index.php and   through digging around in java docs.  Instead I need to pass a  32- bit timestamp. Does anyone have an idea of how to convert the timestamp to 32-bit?     I've dug around for awhile and it seems that java.util.Calendar 's   getTime() returns 32-bit, but I'm unaware of any CF Date/Time   functions which use that under the hood. Thanks, Jon

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Paul Hastings
05/02/2007 03:04 PM

J > <cfset date = dateAdd("d",-1, now())> > <cfset date = createODBCDateTime(date)> you don't need this step. > <cfset udate = date.getTime()> that gives java epoch, *milliseconds* since 1-jan-1970. > through digging around in java docs.  Instead I need to pass a  32- > bit timestamp. unix epoch is *seconds* since 1-jan-1970. either divide the java epoch by 1000 or simply do a dateDiff() from 1-jan-1970 using second date parts.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jon Clausen
05/02/2007 03:17 PM

Thanks, Paul!   I guess I was totally mis-interpreting what the   actual problem was.  I don't know why I had that CreateODBCDateTime   in there...    I  copied  that code out of my scratch file and was   messing around with trying to make sure the timezone info was there.   Thanks for the assist. That does the trick. Jon On May 2, 2007, at 3:03 PM, Paul Hastings wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Root
05/02/2007 03:22 PM

Hah, I totally read Paul's response wrong and now I see he already told you you didn't need the createodbcdatetime() call ;)

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jon Clausen
05/02/2007 03:29 PM

Yeah, you were right though, anyway.  Serves me right for pasting   code from my scratch pad into CF-Talk without making sure it doesn't   suck.  :-) On May 2, 2007, at 3:21 PM, Rick Root wrote: > Hah, I totally read Paul's response wrong and now I see he already > told you you didn't need the createodbcdatetime() call ;)

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Rick Root
05/02/2007 03:18 PM

> J ----- Excess quoted text cut - see Original Post for more ----- It's also worth mentioning that you don't need THIS step: <cfset date = createODBCDateTime(date)> the only purpose for the createODBCDateTime() is to use IN a query, and it's not necessary if you're using cfqueryparam. Rick


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

September 01, 2014

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30         

Designer, Developer and mobile workflow conference