CSharp examples for System:DateTime Calculate
Get Standard Date Time
using System.Globalization; using System.Text.RegularExpressions; using System.Web; using System.Linq; using System.Collections.Generic; using System;/*from ww w . ja v a 2 s. c o m*/ public class Main{ public static string GetStandardDateTime(string fDateTime) { return GetStandardDateTime(fDateTime, "yyyy-MM-dd HH:mm:ss"); } public static string GetStandardDateTime(string fDateTime, string formatStr) { if (fDateTime == "0000-0-0 0:00:00") return fDateTime; DateTime time = new DateTime(1900, 1, 1, 0, 0, 0, 0); if (DateTime.TryParse(fDateTime, out time)) { return time.ToString(formatStr); } else { return "N/A"; } } }