how to get current date in c# code example
Example 1: c# get time
var timeString = DateTime.Now.ToString("hh:mm:ss");
var time24 = DateTime.Now.ToString("HH:mm:ss");
var timeString = DateTime.Now.ToString("t");
var shortTimeStr = DateTime.Now.ToShortTimeString();
var longTimeStr = DateTime.Now.ToLongTimeString();
var longtimestr = DateTime.Now.ToString("T");
var timeSpan = DateTime.Now.TimeOfDay;
Example 2: c# get current date
DateTime now = DateTime.Now;
Example 3: c# get today's date
DateTime today = DateTime.Today;
Example 4: c# datetime current
DateTime now = DateTime.Now;
string strDate = now.ToString("YYYY-MM-dd");