RSS

VBScript: Convert/Split seconds to days, hours, minutes and seconds

03 Aug

This function converts the number of seconds to its day, hour, min and sec components. It returns a comma-delimited string in format “day,hour,min,sec”. You can use the split() function to extract it into an array, example, MyTime = split(SplitSec(449786), “,”)

Function SplitSec(pNumSec)
  Dim d, h, m, s
  Dim h1, m1

  d = int(pNumSec/86400)
  h1 = pNumSec - (d * 86400)
  h = int(h1/3600)
  m1 = h1 - (h * 3600)
  m = int(m1/60)
  s = m1 - (m * 60)

  SplitSec = cStr(d) & "," & cStr(h) & "," & cStr(m) & "," & cStr(s)
End Function
Advertisements
 
Leave a comment

Posted by on August 3, 2011 in Scripts

 

Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: