CSharp examples for System:DateTime Format
Gets the date time string.
using System.Globalization; using System;// w w w . java 2s . c o m public class Main{ /// <summary> /// Gets the date time string. /// </summary> /// <param name="input">The input.</param> /// <returns></returns> public static string GetDateTimeString(this DateTime input) { try { var format = new CultureInfo("en-US", true); return input.ToString("G", format); } catch { return string.Empty; } } }