-3

I'd like to show the date/time, two hours after the current time.

DateTime value = DateTime.Now;
DateTime newvalue = value.AddHours(2);
label5.Text = ???
Nic
  • 12,220
  • 20
  • 77
  • 105
Boom
  • 19
  • 1
  • 6

3 Answers3

2

Something like this seems to be what you want:

label5.Text = DateTime.Now.AddHours(2).ToString("dd/MM/yyyyy hh:mm"); // or whatever format you like
Nic
  • 12,220
  • 20
  • 77
  • 105
0

I don't know what you want to do but you've already added 2 hours to newvalue. You just need to add it to the textbox now, using:

textBox_NameOfTextBox.Text = newvalue.ToString();
Proton
  • 93
  • 2
  • 9
0

label5.Text = newvalue.ToString("yyyy-MM-dd HH:mm");

yes, add date format.

Carlos Muñoz
  • 17,397
  • 7
  • 55
  • 80
Boom
  • 19
  • 1
  • 6