Devo convertire i secondi nel formato 3d, 02:05:45
. Con la funzione qui sotto potrei convertirlo in 3.02:05:45
. Non sono sicuro di come convertirlo nel formato che volevo. Per favore aiuto.Conversione dei secondi in giorni, hh: mm: ss C#
private string ConvertSecondsToDate(string seconds)
{
TimeSpan t = TimeSpan.FromSeconds(Convert.ToDouble(seconds));
if (t.Days > 0)
return t.ToString(@"d\.hh\:mm\:ss");
return t.ToString(@"hh\:mm\:ss");
}
Se provo a fare qualcosa di simile ritorno t.ToString(@"%d , hh\:mm\:ss")
Sto ottenendo un errore,
stringa di input non è nel formato corretto.
u possibile aggiungere ur carattere desiderio nel metodo toString con "\" prima ur carattere ==> t.ToString (@ "d \ d \ , hh \: mm \: ss ") –
puoi fare un esempio? Intendi questo ritorno t.ToString (@ "%., Hh: mm: ss")? – Ramya
Che ha funzionato @Leon_SFS :) – Ramya