This is a migrated thread and some comments may be shown as answers.

how to convert any string value in to time format in javascript or c#

1 Answer 376 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Shubham
Top achievements
Rank 1
Shubham asked on 27 Jan 2012, 05:30 PM
if you know both in c# and javascript please tell me its very urgent......
llike i have values in minute means like 15 in minutes  now i want to convert in to     00:15:00  time format

444444- convert it an to time format please do this for me....
44444 minutes int to 44:60:00
 i dnt know correct conversion of 44444 in to time format please consider this as example.....

1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 01 Feb 2012, 08:45 AM
Hi Shubham,

You can convert an amount of minutes to hours and minutes format by dividing the minutes to 60, which will give you the number of hours. The reminder is the number of minutes left. Below you can check the approach, implemented in C# and JavaScript:

JavaScript
var allMinutes = 530;
var hours = Math.floor(allMinutes / 60);
var minutes = allMinutes % 60;
var time = hours + ":" + minutes;

C#
int allMinutes = 530;
int hours = allMinutes / 60;
int minutes = allMinutes % 60;
string time = hours + ":" + minutes;

Regards,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
General Discussions
Asked by
Shubham
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or