Solved

convert seconds to time(am/pm)

Posted on 2004-09-13
4
341 Views
Last Modified: 2013-12-24
I have the seconds in 55800 format which is 15.5 (3.30pm).
Is there a way to write fn to output this as 3.30pm
thanks
0
Comment
Question by:anusha
  • 2
  • 2
4 Comments
 
LVL 35

Assisted Solution

by:mrichmon
mrichmon earned 25 total points
ID: 12048385
Yes - do the math



<cfset currentsec = 55800>

<cffunction name="getTime">
<cfargument name="mysec" type="numeric" required="true">

<cfset mymin = mysec / 60>

<cfset myhours = mymin / 60>

<cfset timeHours = ListFirst(myhours, '.')>
<cfset timeminutes = ListLast(myhours, '.') * 60>

<cfset thetime = timeHours & ":" & timeminutes>
<cfif timeHours GTE 12>
   <cfset thetime = thetime & " pm">
<cfelse>
   <cfset thetime = thetime & " am">
</cfif>

<cfreturn thetime>
</cffunction>
0
 
LVL 10

Accepted Solution

by:
Mause earned 25 total points
ID: 12051786
hi,

mrichmon some small changes:

<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>


Mause
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 12055350
Yeah that is better, but I was writing quick :o)

Use Mause's solution.
0
 
LVL 10

Expert Comment

by:Mause
ID: 12056573
thx mrichmon

also did some quick writing ;)

why not split the points

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

840 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