datetime class : AddHours(int) method
Description
Gets a new datetime instance which is obtained by adding the number of hours to the invoker instance.
Syntax
datetimeInstance.AddHours(int numberOfHours)
Arguments
Class | Name | Description |
int | numberOfHours | Number of hours |
Return value
Class | Description |
datetime | New datetime type instance which is obtained by adding the argument. |
Sample code
1: | datetime dt = new datetime(2016, 3, 4, 4, 13, 0); |
2: | datetime addHour1 = dt.AddHours(5); // 2016/03/04 9:13:00 |
3: | datetime addHour2 = dt.AddHours(-5); // 2016/03/03 23:13:00 |
Notes
It's a wrapper of the System.DateTime.AddHours(Double) method.