fork(9) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. static DateTime RandomDay()
  6. {
  7. DateTime start = new DateTime(1995, 1, 1);
  8. Random gen = new Random();
  9.  
  10. int range = (DateTime.Today - start).Days;
  11. return start.AddDays(gen.Next(range));
  12. }
  13.  
  14.  
  15. public static void Main()
  16. {
  17. var randomDate = RandomDay();
  18. TimeSpan TimeDifference = DateTime.Now - randomDate;
  19. string result = string.Format(@"{0:hh\:mm\:ss}", TimeDifference);
  20. Console.WriteLine(result);
  21. DateTime dt = DateTime.MinValue.Add(TimeDifference);
  22. result = dt.ToString(@"hh\:mm\:ss");
  23. Console.WriteLine(result);
  24. }
  25. }
Success #stdin #stdout 0.04s 34024KB
stdin
Standard input is empty
stdout
2024.20:15:52.3389740
08:15:52