You are 1 of 15 Active ASP Visitors
 
 
  ASP Home  |  Resources  |  Write a Review  |  My Favor-Its  |  Login
Share on Facebook Tweet this! Share on Google+ Share on LinkedIn Add to Del.icio.us   Add to StumbleUpon eee
 


 
Resource Menu
 Seconds conversionCode Snippet 
7
Reviews
0
Favor-It
I recently needed to convert a time value from a query that was returned as a value of seconds. For example 309786 seconds. I needed to format this into a more user friendly value like 86:03:06 Here is a function to do this. Code: ASP 3.0 & VBScript




User Reviews   
   Authentic (1)  Anonymous (6) 




      
Overall Rating:
Codango PHP, ASP .NET, JSP Scripts, Resources, Reviews
Click to Read Reviews
User
Rated
    
convert seconds to time    
Written by Anonymous User (#1367-245) from UK   (Wednesday, October 13, 2004)
Strengths:   Top job fella  
Weaknesses:   None really, just a weakness with our database programmer  
Details:   had to convert a number stored in a text field so I just stuck FormatNumber in front <%= TimeConvert(FormatNumber(Recordset2.Fields.Item("ct_starttime").Value))%>
Review Based On:   1 Hour(s) of usage  

An addition to..    
Written by Jason Burton from Rockford, MI   (Tuesday, December 23, 2003)
Writer is with: http://www.starloop.com
Strengths:   no comment  
Weaknesses:   no comment  
Details:   Function TimeConvert (Seconds) intSec = CInt(Seconds) 'Set the initial values of the time variables HOURS = 0 MINUTES = 0 SECONDS = 0 'Extract the different time parts from the seconds HOURS = intSec \ 3600 MINUTES = (intSec MOD 3600)\60 SECONDS = (intSec MOD 3600) MOD 60 If Len(HOURS) = 1 then Hours = "0" & HOURS End If If Len(MINUTES) = 1 then Minutes = "0" & Minutes End If If Len(SECONDS) = 1 then Seconds = "0" & SECONDS End If 'TimeConvert = HOURS &" hrs " & MINUTES &" min " & SECONDS & " sec" If NOT HOURS = 00 Then hval = HOURS & " hrs " End If If NOT MINUTES = 00 Then mval = MINUTES & " min " End If If NOT SECONDS = 00 Then sval = SECONDS & " sec" End If TimeConvert = hval & mval & sval End Function This will format date/time to only values with something in it. ie. if 0 hrs, it wont display hrs. Ie. 1 min 3 sec
Review Based On:   1 Hour(s) of usage  

LIFE SAVER    
Written by Anonymous User (#1772-390) from Sacramento, CA   (Monday, June 24, 2002)
Strengths:   no comment  
Weaknesses:   no comment  
Details:   Thank you so much for posting this set of code. I had been spending way too many hours trying to do the exact same thing. You are a life saver.

Small optimization    
Written by Anonymous User (#1833-283) from Ann Arbor, MI   (Thursday, July 12, 2001)
Strengths:   no comment  
Weaknesses:   no comment  
Details:   You can simplify the computation of the seconds a wee bit. Since 60 is a multiple of 3600, you can get away with this: SECONDS = intSec MOD 60

Was "almost" just what I needed.    
Written by Anonymous User (#1649-324) from Eagle Mountain, UT   (Sunday, June 24, 2001)
Strengths:   no comment  
Weaknesses:   no comment  
Details:   This helped me to get what I needed, it wasin't perfect but without it I would have been up the proveribial creek without a paddle. What I need was to output it so it said something like "4 Days, 5:43:12". Or something to that effect. I am trying to build an online type of auction where I wanted to post the time left to bid on an item, in an easy to read and understand way. "4 Days, 5 Hours, 43 Minutes and 32 Seconds" Is very user friendly, but very long to write. So now to figure out the days I devide the HOURS\24 to get the days, but then I have to give HOURS the remainder so it won't say something like 2 Days 52 Hours, instead it should say 2 Days 4 Hours. Seems like that with all the datetime functions microsoft built into ASP, they should have built one that did all this for us.

Many thanx...    
Written by Anonymous User (#1471-161) from Goteborg, Sweden   (Friday, May 11, 2001)
Strengths:   no comment  
Weaknesses:   no comment  
Details:   Perfect...just what I was looking for. Mergatroid, you saved me some valuable time. I'll hope I can return the favor some time.

Great!    
Written by Anonymous User (#1353-102) from India   (Monday, April 23, 2001)
Strengths:   no comment  
Weaknesses:   no comment  
Details:   I needed this code + a bit of customization to help me with a project at work.Thanks I will post the mod at a later stage



 
Shopping Cart

Sponsor
 

 

 

 
   
  Link to Us  |  About Us   Advertise  |  Contact Us  |  Website Help  
Write a User Review Today!
Its Fun, Fast, and Easy!
Web site monitoring by Web Site Monitor - for Android

2014 InfoVertica, LLC, All Rights Reserved *