Lost universe of Programing
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Lost universe of Programing

USERNAME :- Forum Post:-114
 
HomePortalGalleryLatest imagesRegisterLog in

 

 Date and Time in C#

Go down 
AuthorMessage
Administrator
Admin
Admin
Administrator


Male
Number of posts : 160
Age : 38
Location : Lucknow
Job/hobbies : Software Engeener
What U like To do ? : Because Its Rock with me.
Registration date : 2008-01-06

Date and Time  in C# Empty
PostSubject: Date and Time in C#   Date and Time  in C# I_icon_minitime4/9/2008, 7:47 pm

  1. // retrieve and format date/time data
  2. // tested with VCS.NET 2003

  3. using System; // has all the date/time stuff

  4. class myApp
  5. {
  6. public static void Main()
  7. {
  8. DateTime CurrTime = DateTime.Now;

  9. Console.WriteLine("DateTime display listing specifier and result:\n");

  10. Console.WriteLine("d = {0:d}", CurrTime ); // Short date mm/dd/yyyy
  11. Console.WriteLine("D = {0:D}", CurrTime ); // Long date day, month dd, yyyy
  12. Console.WriteLine("f = {0:f}", CurrTime ); // Full date/short time day, month dd, yyyy hh:mm
  13. Console.WriteLine("F = {0:F}", CurrTime ); // Full date/full time day, month dd, yyyy HH:mm:ss AM/PM
  14. Console.WriteLine("g = {0:g}", CurrTime ); // Short date/short time mm/dd/yyyy HH:mm
  15. Console.WriteLine("G = {0:G}", CurrTime ); // Short date/long time mm/dd/yyyy hh:mm:ss
  16. Console.WriteLine("M = {0:M}", CurrTime ); // Month dd
  17. Console.WriteLine("R = {0:R}", CurrTime ); // ddd Month yyyy hh:mm:ss GMT
  18. Console.WriteLine("s = {0:s}", CurrTime ); // yyyy-mm-dd hh:mm:ss can be sorted!
  19. Console.WriteLine("t = {0:t}", CurrTime ); // Short time hh:mm AM/PM
  20. Console.WriteLine("T = {0:T}", CurrTime ); // Long time hh:mm:ss AM/PM
  21. Console.WriteLine("u = {0:u}", CurrTime ); // yyyy-mm-dd hh:mm:ss universal/sortable
  22. Console.WriteLine("U = {0:U}", CurrTime ); // day, month dd, yyyy hh:mm:ss AM/PM
  23. Console.WriteLine("Y = {0:Y}", CurrTime ); // Month, yyyy
  24. Console.WriteLine();
  25. Console.WriteLine("DateTime.Month = " + CurrTime.Month); // number of month
  26. Console.WriteLine("DateTime.DayOfWeek = " + CurrTime.DayOfWeek); // full name of day
  27. Console.WriteLine("DateTime.TimeOfDay = " + CurrTime.TimeOfDay); // 24 hour time

  28. // number of 100-nanosecond intervals that have elapsed since 1/1/0001, 12:00am
  29. // useful for time-elapsed measurements
  30. Console.WriteLine("DateTime.Ticks = " + CurrTime.Ticks);

  31. Console.Read(); // wait
  32. }
  33. }

Back to top Go down
https://aspx.forumotion.com
 
Date and Time in C#
Back to top 
Page 1 of 1
 Similar topics
-
» Extract Date From Date time data type in c#
» Extract Date From Date time data type in c#
» Extract Time From Date time data type in c#
» I need a Project

Permissions in this forum:You cannot reply to topics in this forum
Lost universe of Programing :: --=| SOURCE CODE |=-- :: CODE FOR C# & ASP.NET-
Jump to: