Link to home
Start Free TrialLog in
Avatar of anusha
anusha

asked on

cffunction about converting time

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




Avatar of mrichmon
mrichmon

Use cftry and cfcatch

logic like this :

<cftry>

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

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

</cftry>
ASKER CERTIFIED SOLUTION
Avatar of mrichmon
mrichmon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial