ddmmyyyy hh:mm:ss DateTime format in C#

Last Reply on Mar 10, 2012 11:55 PM By Mudassar

Posted on Mar 09, 2012 06:48 AM

i have a text box where in  i want to display time in hh:mm format

i have the code forhe same as

 if (!DateTime.TryParseExact(txtatime.Text, "hh:mm", null, System.Globalization.DateTimeStyles.None, out Test4) == true)

{

error msg

}

in db i have values as 1900-01-01 00:00:00

but in textbox i get 12:00 AM

 

& error as format shldbe in HH:mm

Posted on Mar 09, 2012 07:05 AM

Try this

string d = DateTime.Now.ToString("dd/mm/yyyy hh:mm:ss");

 


Posted on Mar 10, 2012 01:54 AM Modified on on Mar 10, 2012 01:55 AM

 

string d = DateTime.Now.ToString("dd/MM/yyyy hh:mm tt");


Output

10/03/2012 02:23 PM

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html