Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

cffunction about converting time

Posted on 2004-11-18
3
Medium Priority
?
227 Views
Last Modified: 2013-12-24
All,

I have the following

<cffunction name="getTime">
<cfargument name="mysec" type="numeric" required="true">
<cfset timesec = mysec mod 60>
<cfset timemin = ((mysec - timesec) mod 3600) / 60>
<cfset timehour = (mysec - (timemin*60)) / 3600>
<cfreturn createtime(timehour, timemin, timesec)>
</cffunction>

The input para sometimes has trouble passing "createtime(timehour, timemin, timesec)> "
how do I not get an error if the following fails.

<cfset #ct# = #LSTimeFormat(gettime(ev_ctime),'hh:mm tt')#>

how do I need to modify the fn to get null output if the createtime fails.

Thanks




0
Comment
Question by:anusha
  • 2
2 Comments
 
LVL 35

Expert Comment

by:mrichmon
ID: 12620211
Use cftry and cfcatch

logic like this :

<cftry>

<cfset ct = LSTimeFormat(gettime(ev_ctime),'hh:mm tt')>

<cfcatch>
<cfset ct = "">
</cfcatch>

</cftry>
0
 
LVL 35

Accepted Solution

by:
mrichmon earned 200 total points
ID: 12620223
Or inside the function:

<cffunction name="getTime">
<cfargument name="mysec" type="numeric" required="true">
<cfset timesec = mysec mod 60>
<cfset timemin = ((mysec - timesec) mod 3600) / 60>
<cfset timehour = (mysec - (timemin*60)) / 3600>

<cftry>
<cfset temp = createtime(timehour, timemin, timesec)>
<cfcatch>
<cfset temp = "">
</cfcatch>
</cftry>

<cfreturn temp>
</cffunction>

Then in the page:
<cfset ct = LSTimeFormat(gettime(ev_ctime),'hh:mm tt')>
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
What You Need to Know when Searching for a Webhost Provider
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question