Advertisement
Fhernd

CadenasFormatoFecha.cs

Jul 18th, 2016
902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. DateTime fecha = new DateTime(2013, 3, 22, 19, 13, 31);
  2.  
  3. // Fecha corta: d
  4. Console.WriteLine(fecha.ToString("d"));
  5.  
  6. // Fecha larga: D
  7. Console.WriteLine(fecha.ToString("D"));
  8.  
  9. // Hora corta: t
  10. Console.WriteLine(fecha.ToString("t"));
  11.  
  12. // Hora larga:
  13. Console.WriteLine(fecha.ToString("T"));
  14.  
  15. // Fecha larga + hora corta: f
  16. Console.WriteLine(fecha.ToString("f"));
  17.  
  18. // Fecha larga + hora larga: F
  19. Console.WriteLine(fecha.ToString("F"));
  20.  
  21. // Fecha corta + hora corta: g
  22. Console.WriteLine(fecha.ToString("g"));
  23.  
  24. // Fecha corta + hora larga: G (predeterminado)
  25. Console.WriteLine(fecha.ToString("G"));
  26.  
  27. // Mes y día: m, M
  28. Console.WriteLine(fecha.ToString("m"));
  29.  
  30. // Año y mes: y, Y
  31. Console.WriteLine(fecha.ToString("y"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement