sql >> Base de Datos >  >> RDS >> Mysql

Convierta DateTime para MySQL usando C#

Tenga en cuenta que puede codificar el formato ISO

string formatForMySql = dateValue.ToString("yyyy-MM-dd HH:mm:ss");

o usa siguiente:

// just to shorten the code
var isoDateTimeFormat = CultureInfo.InvariantCulture.DateTimeFormat;

// "1976-04-12T22:10:00"
dateValue.ToString(isoDateTimeFormat.SortableDateTimePattern); 

// "1976-04-12 22:10:00Z"    
dateValue.ToString(isoDateTimeFormat.UniversalSortableDateTimePattern)

y así sucesivamente