Question: I need to format a date to the following format:

`M-d-yyyy`

I tried using:

`string.Format("{0:M-d-yyyy}", DateTime.Now)`

But the output string will depend on the CurrentCulture on the computer where it's run, so sometimes the output might be `07/09/2014` or `07.09.2014` instead of `09-07-2014`.

How can I easily prevent it from converting it based on the culture and treating it as a literal string?

Answer: 
Use `CultureInfo.InvariantCulture` as an `IFormatProvider` parameter:

```
DateTime.Now.ToString("M-d-yyyy", CultureInfo.InvariantCulture);

```
You can set the culture of your program with this:

```
Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;`

```

You can also use a specific culture if you want (I think `en-US` is the one you need)