Write Iso Date and time (Year-Month-Day Hour:Minute) - CSharp System

CSharp examples for System:DateTime Format

Description

Write Iso Date and time (Year-Month-Day Hour:Minute)

Demo Code


using System.Text;
using System.Globalization;
using System.Collections.Specialized;
using System.Collections;
using System;//from   w w  w  .  j av a2s  .co  m

public class Main{
        /// <summary>
        /// Write Iso Date and time (Year-Month-Day Hour:Minute)
        /// </summary>
        public static string WriteIsoDateAndTime( DateTime date )
        {
            return date.Year + "-" +
                date.Month.ToString( "00" ) + "-" +
                date.Day.ToString( "00" ) + " " +
                date.Hour.ToString( "00" ) + ":" +
                date.Minute.ToString( "00" );
        } // WriteIsoDateAndTime(date)
}

Related Tutorials