Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have this code
datetime d='20313-06-03';

console.writeline("\n"+d);

than out put is

03/06/2013 00:00:00

but i want in this format

03/06/2013 00:00
Posted

use this:
C#
d.ToString("dd/MM/yyyy HH:mm");

Note:
MM for two-digits display of month
mm for minutes
HH is for 24-hour display
 
Share this answer
 
v3
Comments
Atul Pachori 8-Oct-13 7:00am    
d is a type of datetime so when we write this code it gives me error
Thanks7872 8-Oct-13 7:02am    
I have never came across such a lazy person like you. You didn't even try once and assumed directly that it will give an error. Dont you see ToString("dd/MM/yyyy HH:mm") at the end of the statement?
You can do it using:

C#
d.ToString("MM/dd/yyyy HH:mm");
 
Share this answer
 
C#
Console.WriteLine("\n {0:dd/MM/yyyy H:mm}", d);
 
Share this answer
 
v3

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