Click here to Skip to main content
15,906,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to remove seconds from this code ......

i like to display only...date , hours and miniutes with AM/PM ...

on my website online ....

cmd.Parameters.AddWithValue("@currentdate", System.DateTime.Now.AddHours(12).AddMinutes(30).ToString());


so how can i get this ...format from (18-08-2014 11:21 am) ...

plz send exact code solution ...for this...
Posted

C#
static string  dateFormats(DateTime dt)
       {

           string outDt;
           outDt = dt.ToString("dd-MM-yyyy") +" "+ String.Format("{0:t}", dt);
           return outDt;
 
Share this answer
 
Comments
safal.786 25-Aug-14 8:52am    
thank you sir ...for your solution ........
C#
DateTime dt= System.DateTime.Now;      
string format = "dd-MM-yyyy hh:mm tt";
string date = dt.ToString(format);
 
Share this answer
 
v2
Comments
safal.786 25-Aug-14 8:53am    
thank you sir ...for your solution ........
Try This,,,

C#
DateTime dt = DateTime.Now;
                string sysDate = string.Empty;
                sysDate = dt.ToString("dd-MM-yyyy") + " " + String.Format("{0:t}", dt);


Thanks...
 
Share this answer
 
Comments
safal.786 25-Aug-14 8:52am    
thank you sir ...for your solution ........

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