Skip to content

Instantly share code, notes, and snippets.

@ashour
Last active April 9, 2020 12:37
Show Gist options
  • Save ashour/31c404ecbe6724c04bf5b744ede3c3d3 to your computer and use it in GitHub Desktop.
Save ashour/31c404ecbe6724c04bf5b744ede3c3d3 to your computer and use it in GitHub Desktop.
using System;
class MainClass
{
public static void Main (string[] args)
{
var dateTime1 = new DateTime(1970, 1, 1, 0, 0, 0);
var dateTime2 = new DateTime(2020, 4, 1, 13, 30, 22, 500);
TimeSpan span = dateTime2 - dateTime1;
Console.WriteLine(span.ToString());
// => 18353.13:30:22.5000000
Console.WriteLine(span.ToString(@"hh\:mm\:ss"));
// => 13:30:22
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment