Michael Sterling
asked on
How do I add leadding zeros for my timespan date parts when I need them?
I have a TimeSpan object that I'm breaking into its individual parts (days, hours, minutes, seconds), as strings, using the ToString() method. How do I ensure that for each part that is a single digit, that I add a leading 0? for example, this: 1:6:45:9 would become this: 01:06:45:09
.
.
.
TimeSpan ts = currentDateTime - signInTime;
return ts.Days.ToString() + ":" + ts.Hours.ToString() + ":" + ts.Minutes.ToString() + ":" + ts.Seconds.ToString();
.
.
.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ts.Days.ToString().length(