Try this function. It takes as attributes, days, hours, minutes, seconds
in that order. But you can call it in the following ways. (The last one
is the one you want):
timespanformat(days, hours, minutes, seconds)
timespanformat(hours, minutes, seconds)
timespanformat minutes, seconds)
timespanformat(seconds)
<cfscript>
function timespanFormat() {
var days = 0;
var hours = 0;
var minutes = 0;
var seconds = 0;
var timespan = 0;
var result = "";
if ( arrayLen(arguments) gt 0 ) {
seconds = arguments[arrayLen(arguments)];
if ( arrayLen(arguments) gt 1 ) {
minutes = arguments[arrayLen(arguments)
- 1];
if ( arrayLen(arguments) gt 2 ) {
hours =
arguments[arrayLen(arguments) - 2];
if ( arrayLen(arguments) gt 3 )
days =
arguments[arrayLen(arguments) - 3];
}
}
}
timespan = ((days * 24 + hours) * 60 + minutes) * 60 +
seconds;
seconds = timespan mod 60;
timespan = timespan \ 60;
minutes = timespan mod 60;
timespan = timespan \ 60;
hours = timespan mod 24;
timespan = timespan \ 24;
days = timespan;
if ( days )
if ( days eq 1 )
result = "1 day";
else
result = days & " days";
if ( hours )
if ( hours eq 1 )
result = listAppend(result, "1 hour");
else
result = listAppend(result, hours & "
hours");
if ( minutes )
if ( minutes eq 1 )
result = listAppend(result, "1 minute");
else
result = listAppend(result, minutes & "
minutes");
if ( seconds )
if ( seconds eq 1 )
result = listAppend(result, "1 second");
else
result = listAppend(result, seconds & "
seconds");
return listChangeDelims(result, ", ");
}
</cfscript>
> -----Original Message-----
> From: Dave Lyons [mailto:[EMAIL PROTECTED]]
> Sent: Friday, 14 February 2003 11:23 a.m.
> To: CF-Talk
> Subject: Re: OK, lets start over........Re: any ideas on this error?
>
>
> ok, that may work
> solves the error and returns this: 159679
> so should i just format that? to show the time left?
>
>
> Dave
>
> ----- Original Message -----
> From: <"Everett>; <Al <[EMAIL PROTECTED]>>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Thursday, February 13, 2003 5:17 PM
> Subject: RE: OK, lets start over........Re: any ideas on this error?
>
>
> > Try this: <cfset timeLeft = DateDiff("s", Now(), deadline)>
> >
> > > -----Original Message-----
> > > From: Dave Lyons [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, February 13, 2003 5:00 PM
> > > To: CF-Talk
> > > Subject: OK, lets start over........Re: any ideas on this error?
> > >
> > >
> > > heres what i need
> > >
> > > i have to make this small auction page for my competitors client.
> > > what i need right now is to be able to show on the details
> > > page how much
> > > time is left before the end of the auction.
> > > see:
> http://www.real-singles.com/auctionCFM/detail.cfm?auctionID=25
> > >
> > > ok, so in my application.cfm template i have this variable set:
> > > <cfset deadline = createDateTime(2003, 2, 15, 13, 42, 0)>
> > >
> > > the reason for this is that i need this to manually set the
> > > end time of the
> > > auction on all of the pages.
> > > they arent paying enough to make it dynamic and they want
> > > each auction to
> > > start and end all at the same time, just a 1 shot deal.
> > > but I figure i should use this for what i need now.
> > >
> > > so on the details page i need to basically show how much time
> > > is left, just
> > > like Ebay:)
> > >
> > > thats where dateDiff comes in, correct?
> > >
> > > which should be like such
> > > <cfset timeLeft = DateDiff("datepart", "date1", "date2")>
> > >
> > > so i was thinking that Now() should go where "date1" is
> > > And "deadline" from the application.cfm should go where "date2" is
> > > tony i think you may be right in putting 's' in where
> "datePart" is
> > >
> > > which now looks like
> > >
> > > <cfset timeLeft = DateDiff("'s'", "Now()", "deadline")>
> > >
> > > and that produces this error
> > >
> > > Parameter validation error for function DATEDIFF.
> > > The value of the parameter 2, which is currently
> > > "Now()", must be a
> > > class java.util.Date value.
> > >
> > > The error occurred in
> > > C:\Inetpub\wwwroot\auctionCFM\datediff.cfm: line
> > > 14
> > >
> > > 12 :
> > > 13 : <body>
> > > 14 : <cfset timeLeft = DateDiff("'s'", "Now()", "deadline")>
> > > 15 :
> > > 16 :
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Dave
> > >
> > > ----- Original Message -----
> > > From: "Tony Weeg" <[EMAIL PROTECTED]>
> > > To: "CF-Talk" <[EMAIL PROTECTED]>
> > > Sent: Thursday, February 13, 2003 4:40 PM
> > > Subject: RE: any ideas on this error?
> > >
> > >
> > > > send the code ur using....
> > > >
> > > > ...tony
> > > >
> > > > Tony Weeg
> > > > Senior Web Developer
> > > > UnCertified Advanced ColdFusion Developer
> > > > Information System Design
> > > > Navtrak, Inc.
> > > > Mobile workforce monitoring, mapping & reporting
> > > > www.navtrak.net
> > > > 410.548.2337
> > > >
> > > > -----Original Message-----
> > > > From: Dave Lyons [mailto:[EMAIL PROTECTED]]
> > > > Sent: Thursday, February 13, 2003 4:36 PM
> > > > To: CF-Talk
> > > > Subject: Re: any ideas on this error?
> > > >
> > > >
> > > > using just Now() throws the same error
> > > >
> > > >
> > > > Dave
> > > >
> > > > ----- Original Message -----
> > > > From: "Tony Weeg" <[EMAIL PROTECTED]>
> > > > To: "CF-Talk" <[EMAIL PROTECTED]>
> > > > Sent: Thursday, February 13, 2003 4:30 PM
> > > > Subject: RE: any ideas on this error?
> > > >
> > > >
> > > > > why use all that....can u just use
> > > > >
> > > > > Now()
> > > > >
> > > > > ...tony
> > > > >
> > > > > Tony Weeg
> > > > > Senior Web Developer
> > > > > UnCertified Advanced ColdFusion Developer
> > > > > Information System Design
> > > > > Navtrak, Inc.
> > > > > Mobile workforce monitoring, mapping & reporting
> > > > > www.navtrak.net
> > > > > 410.548.2337
> > > > >
> > > > > -----Original Message-----
> > > > > From: Dave Lyons [mailto:[EMAIL PROTECTED]]
> > > > > Sent: Thursday, February 13, 2003 4:26 PM
> > > > > To: CF-Talk
> > > > > Subject: any ideas on this error?
> > > > >
> > > > >
> > > > > Parameter validation error for function DATEDIFF.
> > > > > The value of the parameter 2, which is currently
> > > > > "CreateDateTime(Now())", must be a class java.util.Date value.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for
dependable ColdFusion Hosting.
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4