how to convert any date format to dd/mm/yyyy in c# code example

Example 1: c# parse the date in DD/MMM/YYYY format

CultureInfo culture = new CultureInfo("es-ES");
String myDate = "15/05/2018";
DateTime date = DateTime.Parse(myDate,culture);
Console.WriteLine(date.ToString("dd/MMM/yyyy"));

Example 2: Convert a date to yyyy mm dd format

const formatYmd = date => date.toISOString().slice(0, 10);
formatYmd(new Date());

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);
}