Convert # of second in Days / Hours / Minutes / Seconds

P

Personne

I had a vbscript doing this for me, I was thinking converting this
function to PS, but I wonder if a build-in .NET which I can call with
PS was already existing

var filetime = (factor * filesize) / kps[x];
yearmod = filetime % 31557900;
year = Math.floor(filetime / 31557900);
day = Math.floor(yearmod / 86460);
daymod = filetime % 86460;
hour = Math.floor(daymod / 3600);
hourmod = filetime % 3600;
minute = Math.floor(hourmod / 60);
second = Math.floor(filetime % 60);

Input (in sec) : 91500
Returns: 1 Days 1 Hours 25 Minutes 0 Seconds

Thank you for your help
 

My Computer

M

Marco Shaw [MVP]

PS > new-timespan -seconds 91500

Days : 1
Hours : 1
Minutes : 25
Seconds : 0
Milliseconds : 0
Ticks : 915000000000
TotalDays : 1.05902777777778
TotalHours : 25.4166666666667
TotalMinutes : 1525
TotalSeconds : 91500
TotalMilliseconds : 91500000

"Personne" <[email protected]> wrote in message
news:[email protected]

> I had a vbscript doing this for me, I was thinking converting this
> function to PS, but I wonder if a build-in .NET which I can call with
> PS was already existing
>
> var filetime = (factor * filesize) / kps[x];
> yearmod = filetime % 31557900;
> year = Math.floor(filetime / 31557900);
> day = Math.floor(yearmod / 86460);
> daymod = filetime % 86460;
> hour = Math.floor(daymod / 3600);
> hourmod = filetime % 3600;
> minute = Math.floor(hourmod / 60);
> second = Math.floor(filetime % 60);
>
> Input (in sec) : 91500
> Returns: 1 Days 1 Hours 25 Minutes 0 Seconds
>
> Thank you for your help
>
>
>
 

My Computer

D

Dr J R Stockton

In microsoft.public.windows.powershell message <f317de24-cc77-4ce9-ac6d-
[email protected]>, Fri, 28 May 2010 07:32:48,
Personne <[email protected]> posted:

>I had a vbscript doing this for me, I was thinking converting this
>function to PS, but I wonder if a build-in .NET which I can call with
>PS was already existing
>
>var filetime = (factor * filesize) / kps[x];
>yearmod = filetime % 31557900;
>year = Math.floor(filetime / 31557900);
>day = Math.floor(yearmod / 86460);
>daymod = filetime % 86460;
>hour = Math.floor(daymod / 3600);
>hourmod = filetime % 3600;
>minute = Math.floor(hourmod / 60);
>second = Math.floor(filetime % 60);
>
>Input (in sec) : 91500
>Returns: 1 Days 1 Hours 25 Minutes 0 Seconds
There are not always 24 hours in a civil day.
The length of the Gregorian year varies.
The number of seconds in a day is never 86460.
The number of seconds in a year, Gregorian or Julian, is not 31557900.

So you are unlikely to find a matching pre-existent routine.

--
(c) John Stockton, nr London, UK. [email protected] Turnpike v6.05.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
 

My Computer

Top