Literal four = new Literal();
string timeanddate;
timeanddate = DateTime.UtcNow.ToString();
DateTime dt = new DateTime();
DateTime dt_calc = new DateTime();
dt = Convert.ToDateTime(timeanddate);
dt_calc = dt.AddHours(3);
four.Text = "3hr added and this gives>> " + dt_calc.ToString();
form1.Controls.Add(four);
its all in AM PM i want to work with 24hrs
See this page for every way you could possibly want to format a
DateTime.Note that you use “HH” for 24-hour time.
For example, if you wanted the format “23:00:00” instead of “11:00:00 PM” you would use:
By the way, your initialization of your
DateTimevalues withnew DateTime()is unnecessary.