Skip to content

Instantly share code, notes, and snippets.

@ashour
Last active April 9, 2020 13:10
Show Gist options
  • Save ashour/e221f42b1c137a477d438722f6837783 to your computer and use it in GitHub Desktop.
Save ashour/e221f42b1c137a477d438722f6837783 to your computer and use it in GitHub Desktop.
using System;
using System.Globalization;
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("G", new CultureInfo("en-US")));
// => 18353:13:30:22.5000000
Console.WriteLine(span.ToString("G", new CultureInfo("fr-FR")));
// => 18353:13:30:22,5000000
Console.WriteLine(span.ToString("G", new CultureInfo("ml-IN")));
// => 18353:13:30:22.5000000
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment