Click here to Skip to main content
15,913,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to display given datetime in specific format like example:-
C#
DateTime dt = DateTime.Now;

28/05/2012 05:20:49PM
Posted
Updated 29-May-12 20:38pm
v2
Comments
Nithin Sundar 28-May-12 7:56am    
Have you tried using the TimeOfDay property in DateTime.Now?

Please find this articules..


[^]
 
Share this answer
 
Hi,

Use following code to store your format in string.

C#
string formattedDateTime = dt.ToString("dd/MM/yyyy hh:mm:ss tt");



For more details, please visit following link

String Format for DateTime [C#][^]

Thanks,
Imdadhusen
 
Share this answer
 
v2
Comments
Mohamed Mitwalli 30-May-12 2:42am    
5+
Sunasara Imdadhusen 30-May-12 2:45am    
Thanks you very much for your appreciations!
Prosan 31-May-12 1:36am    
good answer my 5

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