DateTime Format

  • Thread starter Thread starter John
  • Start date Start date
J

John

Experts,

How can I format 8/1/2008 into Aug-1-2008?

Thank you very much.
 
C#

DateTime.Parse("8/1/2008").ToString("MMM - dd- yyy");

sry forgot to complete the year.

DateTime.Parse("8/1/2008").ToString("MMM-dd-yyyy");
 
Netmonster said:
sry forgot to complete the year.

DateTime.Parse("8/1/2008").ToString("MMM-dd-yyyy");

That code depends on the setup of Windows.

On my PC it returns Jan-8-2008 !

Use:

DateTime.ParseExact(s, "M/d/yyyy",
CultureInfo.InvariantCulture).ToString("MMM-dd-yyyy")

to enforce the correct interpretation of the input.

Arne
 
[Date type].toString("ddd-MM-yyyy", new CultureInfo("EN-US")), just describe
the syntax.
 

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