Main Page | Report Page

 

  .NET DotNet Forum Index » General Discussion » GetDurationFormat/StrFromTimeInterval equivalent...

Author Message
Mike Gleason jr Couturier...
Posted: Sun May 03, 2009 9:13 am
 
Hi,

Before writing out my own (buggy) function,

I would like to know if there is a .NET built-in function to display
a formatted/localized time duration?

ex.:
- 338 h 45 m 12 s
- 1 min 14 sec
- 3 days 4 hours

Thanks!
 
kurniawirawan...
Posted: Sun May 03, 2009 9:36 pm
 
Try using System.TimeSpan

like this:
TimeSpan tm;
DateTime date1 = new DateTime(2009, 4, 30, 6, 32, 34);
DateTime date2 = new DateTime(2009, 5, 5, 3, 4, 3Cool;
tm = date2 - date1;
Console.WriteLine(\\"Day:{0} - Hour:{1} - Minute: {2} - Second:{3}\\",
tm.Days, tm.Hours, tm.Minutes, tm.Seconds);


--
kurniawirawan
 
Mike Gleason jr Couturier...
Posted: Mon May 04, 2009 2:00 pm
 
"kurniawirawan" <guest at (no spam) unknown-email.com> a écrit dans le message de news:
e9bc2a27074679e67115fbc67f92cfd7 at (no spam) nntp-gateway.com...
Quote:

Try using System.TimeSpan

like this:
TimeSpan tm;
DateTime date1 = new DateTime(2009, 4, 30, 6, 32, 34);
DateTime date2 = new DateTime(2009, 5, 5, 3, 4, 3Cool;
tm = date2 - date1;
Console.WriteLine(\\"Day:{0} - Hour:{1} - Minute: {2} - Second:{3}\\",
tm.Days, tm.Hours, tm.Minutes, tm.Seconds);


--
kurniawirawan

Alright that's what I tought!

thanks kurniawirawan (ok I agree, I copy/pasted your name)
 
Cor Ligthert[MVP]...
Posted: Tue May 05, 2009 12:27 am
 
Then why did you not show that code, this is not a puzzle newsgroup.

Cor

"Mike Gleason jr Couturier" <nospam at (no spam) invalidhost.com> wrote in message
news:O7VrzLPzJHA.3476 at (no spam) TK2MSFTNGP05.phx.gbl...
Quote:

"kurniawirawan" <guest at (no spam) unknown-email.com> a écrit dans le message de news:
e9bc2a27074679e67115fbc67f92cfd7 at (no spam) nntp-gateway.com...

Try using System.TimeSpan

like this:
TimeSpan tm;
DateTime date1 = new DateTime(2009, 4, 30, 6, 32, 34);
DateTime date2 = new DateTime(2009, 5, 5, 3, 4, 3Cool;
tm = date2 - date1;
Console.WriteLine(\\"Day:{0} - Hour:{1} - Minute: {2} - Second:{3}\\",
tm.Days, tm.Hours, tm.Minutes, tm.Seconds);


--
kurniawirawan

Alright that's what I tought!

thanks kurniawirawan (ok I agree, I copy/pasted your name)

 
Mike Gleason jr Couturier...
Posted: Tue May 05, 2009 6:59 am
 
This is what I thought I will have to do on my own if no function existed...
No code was done yet..

This was some planning, you know, thinking ahead

Don't mess around while you're having your PMS
 
Mike Gleason jr Couturier...
Posted: Tue May 05, 2009 7:01 am
 
Oh and btw, I didn't ask for code:

"I would like to know if there is a .NET built-in function to display
a formatted/localized time duration?"
 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Sun Jul 24, 2016 7:20 pm