I have the following codes in visual basic that display the day/month/year
CStr(vDay) & "/" & (vMonth) & "/" & (vYear) & " " & (vHour) & ":" & (vMinute) & ":" & (vSecond), DateTime.Now
How can I add a “0” in front of a single digit day and month?
If your variables are integers, you can use the “D” format specifier to set how many digits you want, for instance:
However, if you already have the value in a
Dateobject, then you can just use it’s built-in formatting, which would be easier: