tags:

views:

50

answers:

2
("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");

doesn't works ...

+3  A: 

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".
Andrew Bezzub
+1  A: 

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");
Sohnee
yes >_< I've tried x.AddHours(1).Hour.ToString("HH"); thank you
nCdy