I am able to get date and time using:
DateTime now = DateTime.Now;
How can I get the current date and time separately in the DateTime forma
Current Time :
DateTime.Now.ToString("HH:mm:ss");
Current Date :
DateTime.Today.ToString("dd-MM-yyyy");
DateTime.Now.ToString("dd/MM/yyyy");
string now = Convert.ToString(DateTime.Now.ToShortDateString());
Console.WriteLine(now);
Console.ReadLine();
There is no built-in date-only type in .NET.
The convention is to use a DateTime with the time portion set to midnight.
The static DateTime.Today property will give you today's date.
Use DateTime.Today property. It will return date component of DateTime.Now. It is equivalent of DateTime.Now.Date.
You can use following code to get the date and time separately.
DateTime now = DateTime.Now;
string date = now.GetDateTimeFormats('d')[0];
string time = now.GetDateTimeFormats('t')[0];
You can also, check the MSDN for more information.