CSharp examples for System:DateTime Format
Write specified date as yyyy-MM-dd
using System.Xml.Serialization; using System.Collections; using System.Globalization; using System.Collections.Specialized; using System.Text; using System.Collections.Generic; using System;//from www.j a va2 s . co m public class Main{ /// <summary> /// Write specified date as yyyy-MM-dd /// </summary> /// <param name="dateTime">The date.</param> /// <returns>string representation of date.</returns> public static string DateToStringSortable(DateTime dateTime) { return dateTime.ToString("yyyy'-'MM'-'dd"); } }