Date Of Diff Minutes - CSharp System

CSharp examples for System:DateTime Minute

Description

Date Of Diff Minutes

Demo Code


using System.Globalization;
using System.Text.RegularExpressions;
using System.Web;
using System.Linq;
using System.Collections.Generic;
using System;/*from  w  w  w . j  av  a  2s  .  com*/

public class Main{
            public static int DateOfDiffMinutes(string time, int minutes)
            {
                if (string.IsNullOrEmpty(time)) return 1;
            // DateTime dateTime = TypeHelper.StrToDateTime(time, DateTime.Parse("1900-01-01"));
            DateTime dateTime = DateTime.Parse("1900-01-01");
            if (dateTime.ToString("yyyy-MM-dd") == "1900-01-01") return 1;
                TimeSpan ts = DateTime.Now - dateTime.AddMinutes(minutes);
                if (ts.TotalMinutes > int.MaxValue)
                {
                    return int.MaxValue;
                }
                else if (ts.TotalMinutes < int.MinValue)
                {
                    return int.MinValue;
                }
                return (int)ts.TotalMinutes;
            }
}

Related Tutorials