Reputation: 3171
Literal four = new Literal();
string timeanddate;
timeanddate = DateTime.UtcNow.ToString();
DateTime dt = new DateTime();
dt = Convert.ToDateTime(timeanddate);
dt.AddHours(3);
four.Text = "3hr added and this gives>> " + dt.ToString();
form1.Controls.Add(four);
It should add 3 to hrs but does not, it's like the line addhours does not exist.
Upvotes: 0
Views: 69
Reputation: 128307
The DateTime
type is immutable.
Luckily, the solution is quite simple:
dt = dt.AddHours(3);
Upvotes: 5