find the date,time,

Gow.net
Posted by Gow.net under C# category on | Points: 40 | Views : 1312
 string defaultdt = DateTime.Now.ToShortDateString() + " " + DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() +"PM";

Comments or Responses

Posted by: Blessyjees on: 2/1/2012 Level:Bronze | Status: [Member] | Points: 10
Hi Gow,

What you mean by this code.
Posted by: T.saravanan on: 2/1/2012 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi,

Nice info.
But we can get easily your output by using the below code..

string defaultdt = DateTime.Now.ToString();  // Output: 2/1/2012 2:51:32 AM

defaultdt = DateTime.Now.ToString("dd/MM/yyyy hh:mm") + " PM"; // Output: 01/02/2012 02:48 PM
defaultdt = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss") + " PM"; // Output: 01/02/2012 02:49:08 PM
defaultdt = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss") + " PM"; // Output: 02/01/2012 02:53:54 PM
defaultdt = DateTime.Now.ToString("dd MMM yyyy hh:mm:ss") + " PM"; // Output: 01 Feb 2012 02:54:17 PM

Login to post response