If you already have a string, you can write
str = str.PadLeft(2, '0');
Please note that you can search
string str = new DateTime(1,1,1, 12,34,56).ToShortTimeString();
This returns 12:34 PMand can be customized using format strings .
SLaks source
share