Hola a Todos,
Aquí les dejo unos simples truquillos de convertir Segundos a Minutos, Horas y Días. Utilizando TimeSpan.
Nota: el Response.Write es por que utilice una pagina ASP.net y en el Load cargaba el resultado :)
En Visual Basic:
Dim segundos As Double = 7950 'Los Segundos a Probar
'Prueba 1: Total Dias, Total de Horas, Total Minutos, Total Segundos
Dim t As New TimeSpan
Response.Write("Prueba 1: Dias: " + t.FromSeconds(segundos).TotalDays.ToString() +
" Tiempo: " + t.FromSeconds(segundos).TotalHours.ToString() + ":" +
t.FromSeconds(segundos).TotalMinutes.ToString() + ":" + t.FromSeconds(segundos).TotalSeconds.ToString())
'Prueba 2: Dias, Hora, Minutos y Segundos
Dim t2 As TimeSpan = TimeSpan.FromSeconds(segundos)
Response.Write("<br> Prueba 2: Dias: " + t2.Days.ToString() + " Tiempo: " +
t2.Hours.ToString() + ":" + t2.Minutes.ToString() + ":" +
t2.Seconds.ToString())
En C#:
double segundos=7950 ; //Los Segundos a probar
TimeSpan t =new TimeSpan;
//Prueba 1: Total Dias, Total de Horas, Total Minutos, Total Segundos
Response.Write("Prueba 1: Dias: " + t.FromSeconds
(segundos).TotalDays.ToString() + " Tiempo: " + t.FromSeconds
(segundos).TotalHours.ToString() + ":" + t.FromSeconds
(segundos).TotalMinutes.ToString() + ":" + t.FromSeconds
(segundos).TotalSeconds.ToString());
TimeSpan t2= TimeSpan.FromSeconds(segundos);
//Prueba 2: Dias, Hora, Minutos y Segundos
Response.Write("<br> Prueba 2: Dias: " + t2.Days.ToString() + " Tiempo: " +
t2.Hours.ToString() + ":" + t2.Minutes.ToString() + ":" +
t2.Seconds.ToString());
Comparte este post: