CSharp examples for System:DateTime Second
Date Of Diff Seconds
using System.Globalization; using System.Text.RegularExpressions; using System.Web; using System.Linq; using System.Collections.Generic; using System;// w ww .j a v a2 s.c o m public class Main{ public static int DateOfDiffSeconds(string time, int Sec) { if (string.IsNullOrEmpty(time)) return 1; DateTime dateTime = DateTime.Parse("1900-01-01"); if (dateTime.ToString("yyyy-MM-dd") == "1900-01-01") return 1; TimeSpan ts = DateTime.Now - dateTime.AddSeconds(Sec); if (ts.TotalSeconds > int.MaxValue) { return int.MaxValue; } else if (ts.TotalSeconds < int.MinValue) { return int.MinValue; } return (int)ts.TotalSeconds; } }