Get the short date string from a date as an object. - CSharp System

CSharp examples for System:DateTime Format

Description

Get the short date string from a date as an object.

Demo Code


using System.Globalization;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from w w  w .  jav a  2  s  . com*/

public class Main{
        /// <summary>
        /// Get the short date string from a date as an object.
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public static string GetShortDate(object date)
        {
           if (date == null) return null;
           return Convert.ToDateTime(date).ToShortDateString();
        }
}

Related Tutorials