Skip to content

Instantly share code, notes, and snippets.

@Yushell
Created September 10, 2013 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yushell/6515905 to your computer and use it in GitHub Desktop.
Save Yushell/6515905 to your computer and use it in GitHub Desktop.
Get DateTime.Now Day, Month, Year in Spanish & different formats
CultureInfo ci = new CultureInfo("es-ES");
// 29
string vDia = Convert.ToString(DateTime.Now.Day);
// AGO
string vMes = Convert.ToString(DateTime.Now.ToString("MMMM", ci).ToUpper().Substring(0, 3));
// 2012
string vAnio = Convert.ToString(DateTime.Now.Year);
// 08
string vMesNumero = Convert.ToString(DateTime.Now.ToString("MM"));
System.DateTime today = System.DateTime.Now;
// Calcular fecha 35 dias atras
DateTime vMes1 = today.Add(new TimeSpan(-35, 0, 0, 0));
// AGO 2012
string vMes1MES = Convert.ToString(vMes1.ToString("MMMM yyyy", ci).ToUpper().Substring(0, 3) + " " + Convert.ToString(vMes1.ToString("yyyy", ci).ToUpper()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment