CSharp examples for System:DateTime Format
Get the formatted date string from a date as an object.
using System.Globalization; using System.Text; using System.Linq; using System.Collections.Generic; using System;/*from ww w .j a v a 2 s . c o m*/ public class Main{ /// <summary> /// Get the formatted date string from a date as an object. /// </summary> /// <param name="date"></param> /// <param name="format"></param> /// <returns></returns> public static string GetDateFormatted(object date, string format) { if (date == null) return null; var tmp = Convert.ToDateTime(date); return tmp.ToString(format); } }