datetime format in c# yyyymmddhhmmss code example Example: C# datetime.now to string only numbers DateTime.Now.ToString("yyyyMMddHHmmss"); // case sensitive