time conversion

A

Andrew

Hi,
How can I convert seconds to hh:mm:ss format? e.g. 123456s = 34:17:36
Thanks
 
S

Steven Burn

Look into the Format function;

e.g.: Response.Write Format(Time(), "hhmmss")

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
S

Steven Burn

I've got it working just fine in one of my scripts. (working alongside FSO)

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
D

Dave Anderson

Andrew said:
How can I convert seconds to hh:mm:ss format?
e.g. 123456s = 34:17:36

Number.prototype.pad = function(d) {
var val = String(this)
d = Math.max(d,val.length)
for (var i=0; i<d; i++) val = "0" + val
return val.substring(val.length-d)
}

var seconds = 123456,
hh = Math.floor(seconds/3600),
mm = Math.floor(seconds%3600/60),
ss = seconds%60

return hh.pad(2) + ":" + mm.pad(2) + ":" + ss.pad(2)

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
B

Bob Barrows

Uummm, this is vbscript, not vb/vba. No builtin Format() function in
vbscript.

Besides, this will not convert an integer containing a number of seconds to
a string in hh:mm:ss format.

Steven said:
Look into the Format function;

e.g.: Response.Write Format(Time(), "hhmmss")

Bob Barrows
 
F

freaky friday

I've got it working just fine in one of my scripts. (working alongside
FSO)

Format is VB / VBA, not VBScript. So the only way you could have it working
is if you had a custom format() function, like the one in one of foo's
links.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top