Formating

  • Thread starter Thread starter MFRASER
  • Start date Start date
M

MFRASER

How do I format a string to contain 0 place holders?

I want the following string "1/1/2001"
to look like "01/01/2001"
 
Hi,
Use the following line of code

Convert.ToDateTime("01/01/2001").ToString("MM/dd/yyyy");

Regards,
Amal
 
Is there a way to code this so that the date will reflect the region of
the computer?

for example

US = "mm/dd/yyyy"
Mex = "dd/mm/yyyy"

etc
 
Fraser Michael said:
Is there a way to code this so that the date will reflect the region of
the computer?

for example

US = "mm/dd/yyyy"
Mex = "dd/mm/yyyy"

Yes - look up "standard date and time format strings" in the MSDN
index.
 
Back
Top