Connecting Tech Pros Worldwide Help | Site Map

how to display datetime format as yyyyMMddHHmmss?

Newbie
 
Join Date: Oct 2009
Location: Bangalore
Posts: 6
#1: Oct 1 '09
like year month date hour minute second....? example- 19880413233510
PRR PRR is offline
Moderator
 
Join Date: Dec 2007
Location: India
Posts: 699
#2: Oct 1 '09

re: how to display datetime format as yyyyMMddHHmmss?


Expand|Select|Wrap|Line Numbers
  1. DateTime d = DateTime.Now;
  2.             Console.WriteLine(d.ToString("yyyy/MM/dd/HH:mm:ss"));
  3. Console.WriteLine(d.ToString("yyyyMMddHHmmss"));
  4.  
  5.  
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,148
#3: Oct 1 '09

re: how to display datetime format as yyyyMMddHHmmss?


All you had to do was plug the number format into the .ToString().
MSDN has examples of this.
Familiar Sight
 
Join Date: Jul 2009
Location: Calgary, Alberta, Canada
Posts: 211
#4: Oct 1 '09

re: how to display datetime format as yyyyMMddHHmmss?


FYI
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

:)
Reply