posted 12/22/2008 by Vivek Thakur
Here are a few handy string formats to convert a given datetime to custom formats://save today's date in a stringstring date = DateTime.Now.Date;1. Show Date as " Friday 13 August 2003" date.DayOfWeek + " " + date.Day + " " + date.ToString("MMMM") + " " + date.Year.ToString()2. Show date as "Friday 13 August 13:00:13" //time in 24H format date.DayOfWeek + " " + date.Day + " " + date.ToString("MMMM") + " " + date.ToString("HH:mm:ss")3. Show date in 12H format with AM/PM as: "Friday 13 August 01:00:13 PM" date.DayOfWeek + " " + date.Day + " " + date.ToString("MMMM") + " " + date.ToString("hh:PM:mm:ss:tt")
hi,
i recently tried to insert a date in a windows application with datetime picker, but it did not allow me to edit time.
secondly when i tried to use custom formats, it threw an exception, saying cannot convert string to datetime
can u please help?
What kind of email newsletter would you prefer to receive from CodeAsp.Net?18