Click here to Skip to main content
16,011,578 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hello experts


how to convert date and time format give any code with example
Posted

 
Share this answer
 
Do you mean string representation of a date? Check the link
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^]
 
Share this answer
 
convert dateTime format means ?
do you want to convert to DD/MM/YYYY and MM/DD/YYYY. OR convert any string to dateTime.

OK. here is example to convert current dateTime to different format.

C#
DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss"), output :04/11/2011 12:01:24

DateTime.Now.ToString("MM/dd/yy hh:mm"), output :11/04/11 12:01

DateTime.Now.ToString("MM/d/yyyy hh:mm"), output :11/4/2011 12:01


These are few example. you can customize dateTime format as you want.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900