Write specified date as yyyy-MM-dd - CSharp System

CSharp examples for System:DateTime Format

Description

Write specified date as yyyy-MM-dd

Demo Code


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");
		}
}

Related Tutorials