("dd/MM/yyyy HH")+ " - " + (x.Hour+1).ToString();
So here is example
what I got and what I need :
0 ---> 00
3 ---> 03
12 ---> 12
How can I use ToString for it ?
I've tried :
x.ToString("dd/MM/yyyy HH") + " - " + x.AddHours(1).ToString("HH");
does开发者_JAVA技巧n't works ...
If you just need to make int.ToString having sum leading zeros you can do it like this:
int integer = 5;
string str = integer.ToString("00"); // str has "05".
Assuming that x is a valid DateTime, this example works (9am appears as "09").
DateTime x = DateTime.Now;
string hours = x.AddHours(1).ToString("HH");
精彩评论