c# datetime tostring format yyyymmddhhmmss code example

Example 1: c# tostring mmm dd yyyy

DateTime.Today.ToString("MMM dd, yyyy");

Example 2: C# datetime.now to string only numbers

DateTime.Now.ToString("yyyyMMddHHmmss"); // case sensitive

Example 3: c# date string format yyyy-mm-dd

public static string FORMAT_PDF = "dd/MM/yyyy";
public static string convertDateTimeFormatByStrDate(string strDate,string format)
{
	DateTime temp = Convert.ToDateTime(strDate);
	return temp.ToString(format);
}

Tags:

Php Example