Q:

Write a C# Sharp program to get a DateTime value that represents the current date and time on the local computer

0

Write a C# Sharp program to get a DateTime value that represents the current date and time on the local computer.

Expected Output :

English (Ireland):                                                      
   Local date and time: 20/08/2016 15:49:03, Local                      
   UTC date and time: 20/08/2016 10:19:03, Utc                          
                                                                        
English (South Africa):                                                 
   Local date and time: 2016-08-20 03:49:03 PM, Local                   
   UTC date and time: 2016-08-20 10:19:03 AM, Utc

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Globalization;
public class Example5
{
   public static void Main()
   {
      DateTime localDate = DateTime.Now;
      DateTime utcDate = DateTime.UtcNow;
      String[] cultureNames = { "en-IE", "en-ZA", "fr-CA",
                                "de-CH", "ro-RO" } ;
      foreach (var cultureName in cultureNames) {
         var culture = new CultureInfo(cultureName);
         Console.WriteLine("{0}:", culture.NativeName);
         Console.WriteLine("   Local date and time: {0}, {1:G}",
                           localDate.ToString(culture), localDate.Kind);
         Console.WriteLine("   UTC date and time: {0}, {1:G}\n",
                           utcDate.ToString(culture), utcDate.Kind);
      }
   }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now