Adding minutes to a datetime variables
Sometime we stuck in a problem in which we have to get a time which is after 20 or 60 minutes then there is simple function which can add minutes to a particular datetime variable
take an example we want to add 60 minutes to present time, for this we simply do is make an 2 objects of current datetime class i.e. date1 and date2
System.DateTime date1 = System.DateTime.Now; System.DateTime date2 = System.DateTime.Now;
after that simply add 60 minutes to the second datetime object created earlier with the help of AddMinutes method like below
System.DateTime date2new = date2.AddMinutes(60);
Method * Description Add Adds a timespan value AddDays Adds a certain number of days AddHours Adds a certain number of hours AddMilliseconds Adds a certain number of Milliseconds AddMinutes Adds a certain number of minutes AddMonths Adds a certain number of months AddSeconds Adds a certain number of seconds AddTicks Adds a certain number of ticks AddYears Adds a certain number of years GetDateTimeFormats Returns a list of available datetime formats GetHashCode Returns hashcode for a certain date. int is returned IsDaylightSavingTime Determines if a datetime object is daylightsavings Subtract Subtracts a timespan object from datetime object ToBinary Serializes object to long value to be used later ToFileTime Converts datetime to a windows file time ToLocalTime Returns a local time object as datetime ToLongDateString Returns a string as a longdate format ToLongTimeString Returns a string as a long time format ToOADate Converts a datetime object to a OLE automation date ToShortDateString Returns a short date format ToShortTimeString Returns a short time format ToString Returns a string that represents the datetime object
* http://www.meshplex.org/wiki/C_Sharp/Da ... nd_Objects
About the author:
PlanetSourceCode.in is a place for all developer providing free source codes, articles, MCA complete projects,complete application in PHP, C/C++, Javascript, Visual Basic, Cobol, Pascal, ASP/VBScript, AJAX, SQL, Perl, Python, Ruby, Mobile Development
Comments
nice useful post
post is very useful one for me
WiEuIlVzyBjC
Wow! That's a really neat asnewr!
Pages
Add new comment