Solved

convert seconds to time(am/pm)

Posted on 2004-09-13
4
329 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now