Posted By

strelaras on 03/06/13


Tagged

time date format DateTime


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

heathbo
danfinrud55


DateTime methods


 / Published in: C#
 

URL: http://msdn.microsoft.com/en-us/library/az4se3k1.aspx

(more examples to be added)

  1. //Standard Date and Time Format Strings: http://msdn.microsoft.com/en-us/library/az4se3k1.aspx
  2.  
  3. DateTime dt = DateTime.Now;
  4.  
  5. // If today is 22 Nov 2012
  6. Console.WriteLine(dt.ToString("dMyyyy")); // 22112012
  7. Console.WriteLine("{0:dMyyyy}", dt); // 22112012
  8.  
  9. // Use DateTime to find elapsed time.
  10. DateTime startTime = DateTime.Now;
  11. TimeSpan timeTaken = DateTime.Now.Subtract(startTime);

Report this snippet  

You need to login to post a comment.