Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have value 1013 in integer format.
I want to show output as 16:53 as HH:mm.
How to show. Pls help me.
Thanks in advance.
Posted

hii,
try
this
1)
C#
int number = 1013;
DateTime baseDate = new DateTime(1900, 1, 1);
string time = (baseDate.AddMinutes(number)).ToString("HH:mm");


2)

C#
int number = 1013;

string time= (number / 60).ToString("00")+":"+(number%60).ToString("00");
 
Share this answer
 
v3
Comments
SamWakchaure 28-Sep-12 6:59am    
thanks it works..
Ganesh Nikam 28-Sep-12 7:10am    
if it will help you mark it as accepted thank you
Do you mean this?
C#
TimeSpan ts = TimeSpan.FromMinutes(1013);
MessageBox.Show(ts.ToString(@"hh\:mm"));
 
Share this answer
 
That's an easy one:

Try this:

C#
int minutes = 1013;
DateTime dMinutes = DateTime.MinValue.AddMinutes(seconds);
string sMinutes = dSeconds.ToString("HH:mm");
 
Share this answer
 
v3
Comments
Herman<T>.Instance 28-Sep-12 6:19am    
good one!
CPallini 28-Sep-12 6:22am    
It is an easy one, but neverthless, wrong... :-D
You should use minutes instead of seconds.
My 5, anyway.
SamWakchaure 28-Sep-12 6:25am    
It's not working..
Giving error as Min.
Ganesh Nikam 28-Sep-12 6:36am    
have you tested this code? it gives error.
Stephen Hewison 28-Sep-12 7:04am    
Sorry, instead of Min it should of been MinValue. With Intellisence in VS I'd thought someone could of worked that out. And yes, it's minutes not seconds. I've updated the solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900