Lost universe of Programing

USERNAME :- Guest Forum Post:-114
 
HomePortalGalleryRegisterLog in

Share | 
 

 Date and Time in C#

Go down 
AuthorMessage
Administrator
Admin
Admin
avatar

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

PostSubject: Date and Time in C#   4/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🇲🇲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🇲🇲ss
  16. Console.WriteLine("M = {0:M}", CurrTime ); // Month dd
  17. Console.WriteLine("R = {0:R}", CurrTime ); // ddd Month yyyy hh🇲🇲ss GMT
  18. Console.WriteLine("s = {0:s}", CurrTime ); // yyyy-mm-dd hh🇲🇲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🇲🇲ss AM/PM
  21. Console.WriteLine("u = {0:u}", CurrTime ); // yyyy-mm-dd hh🇲🇲ss universal/sortable
  22. Console.WriteLine("U = {0:U}", CurrTime ); // day, month dd, yyyy hh🇲🇲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. }


_________________

""-(`v)-"HACKER OF HEART"-(`v)-"

Back to top Go down
View user profile http://aspx.forumotion.com
 
Date and Time in C#
Back to top 
Page 1 of 1

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: