Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# convert seconds to time(am/pm)

Posted on 2004-09-13
Medium Priority
357 Views
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
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
• 2
• 2

LVL 35

Assisted Solution

mrichmon earned 100 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

Mause earned 100 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

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

Use Mause's solution.
0

LVL 10

Expert Comment

ID: 12056573
thx mrichmon

also did some quick writing ;)

why not split the points

0

## Featured Post

Question has a verified solution.

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

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.
What You Need to Know when Searching for a Webhost Provider
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
###### Suggested Courses
Course of the Month8 days, 23 hours left to enroll