c# - DateTime specifier with spaces -
i have example following date time
datetime dt = new datetime(2013,18,04,22,23,0);
this date should represented like
18-04-2013 22:23 environment.newline
worth mention there spaces between number 3 (of 22:23) , environment.newline. so, field length 20characters beggining e letter (of environment.newline).
how can represent date in format spaces?
thanks
i use combination of standard date formatting , non-date-specific string format codes:
string.format("{0:mm-dd-yyyy hh:mm} \n", dt);
or if length "20" important:
string.format("{0,-20:mm-dd-yyyy hh:mm}\n", dt);
this "pads" string 20 characters , left-justifies it. way you're still @ 20 characters if decides change date format (e.g. not pad zeros)
Comments
Post a Comment