Short Date Format

  • Thread starter Thread starter john bailo
  • Start date Start date
J

john bailo

If I use

DateTime.Now.ShortDateFormat().ToString it returns

10/8/2003

What I want is

10/08/2003

Is there an easy way to get DateTime.Now to return
the date with the leading zero.
 
john bailo said:
If I use

DateTime.Now.ShortDateFormat().ToString it returns

10/8/2003

What I want is

10/08/2003

Is there an easy way to get DateTime.Now to return
the date with the leading zero.

DateTime.Now.ToString("dd/MM/yyyy", DateTimeFormatInfo.InvariantInfo);
 
DateTime.Now.ToString("dd/MM/yyyy", DateTimeFormatInfo.InvariantInfo);

works perfect.

requires a reference to System.Globalization ( for using the
DateTimeFormatInfo class)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top