Solved

convert seconds to time(am/pm)

Posted on 2004-09-13
4
350 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

719 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