c# how to get datetime for now code example Example: c# datetime current DateTime now = DateTime.Now; string strDate = now.ToString("YYYY-MM-dd");