using System; using System.Globalization; class Program { static void Main(string[] args) { DateTime date = new DateTime(2021, 11, 4, 14, 35, 0); Console.WriteLine("Date and Time in various formats using IFormatProvider:"); // Format the DateTime using the "en-US" culture CultureInfo ci = new CultureInfo("en-US"); Console.WriteLine(date.ToString("d", ci)); Console.WriteLine(date.ToString("D", ci)); Console.WriteLine(date.ToString("f", ci)); Console.WriteLine(date.ToString("F", ci)); Console.WriteLine(date.ToString("g", ci)); Console.WriteLine(date.ToString("G", ci)); Console.WriteLine(date.ToString("m", ci)); Console.WriteLine(date.ToString("M", ci)); Console.WriteLine(date.ToString("r", ci)); Console.WriteLine(date.ToString("R", ci)); Console.WriteLine(date.ToString("s", ci)); Console.WriteLine(date.ToString("t", ci)); Console.WriteLine(date.ToString("T", ci)); Console.WriteLine(date.ToString("u", ci)); Console.WriteLine(date.ToString("U", ci)); Console.WriteLine(date.ToString("y", ci)); Console.WriteLine(date.ToString("Y", ci)); // Format the DateTime using the "fr-FR" culture ci = new CultureInfo("fr-FR"); Console.WriteLine(date.ToString("d", ci)); Console.WriteLine(date.ToString("D", ci)); Console.WriteLine(date.ToString("f", ci)); Console.WriteLine(date.ToString("F", ci)); Console.WriteLine(date.ToString("g", ci)); Console.WriteLine(date.ToString("G", ci)); Console.WriteLine(date.ToString("m", ci)); Console.WriteLine(date.ToString("M", ci)); Console.WriteLine(date.ToString("r", ci)); Console.WriteLine(date.ToString("R", ci)); Console.WriteLine(date.ToString("s", ci)); Console.WriteLine(date.ToString("t", ci)); Console.WriteLine(date.ToString("T", ci)); Console.WriteLine(date.ToString("u", ci)); Console.WriteLine(date.ToString("U", ci)); Console.WriteLine(date.ToString("y", ci)); Console.WriteLine(date.ToString("Y", ci)); } }In this example, we use the IFormatProvider interface to format a DateTime object in different ways using different cultures. We create instances of the CultureInfo class to specify the culture we want to use for formatting. We then use the ToString method to format the DateTime object according to the specified format string and culture. Package Library: System.Globalization.