I am working with windows server with its English version, but on the client system it takes the date format in "M / d / yyyy".
Already change the language and date format of the server but it is not changed.
Any ideas?
I am working with windows server with its English version, but on the client system it takes the date format in "M / d / yyyy".
Already change the language and date format of the server but it is not changed.
Any ideas?
If you mean that you want to set the text from a DateTime
object without having to write a lot of your own code, maybe this is what you are looking for:
using System.Globalization;
///
DateTimeFormatInfo MxFormat = new CultureInfo("es-MX", false).DateTimeFormat;
string Fecha = DateTime.Now.ToString(MxFormat.LongDatePattern);
EDIT
According to what you mention, you want to convert a String
to a DateTime
. To do it respecting the format in Spanish dd/mm/aaaa
you must do it like this:
DateTime dt; // A esta variable asignarás el valor.
if (DateTime.TryParseExact(MiString, //Primero la variable
"dd/MM/yyyy", //El formato esperado
CultureInfo.InvariantCulture, //Información de cultura
DateTimeStyles.None, //Formato de análisis
out dt)) //Variable a la que se asignará el valor
{
// la fecha es válida
}
else
{
// la fecha no es válida
}