c# datetime tostring yyyy-MM-dd hh mm ss ff code example Example: c# date to string yyyy-mm-dd var date_string = date.ToString("yyyy-MM-dd");