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 the following:

```
DateTime.Now.ToString("d", DateTimeFormatInfo.InvariantInfo);

```

or apply other formatting specs as detailed in <http://msdn.microsoft.com/en-us/library/az4se3k1%28v=vs.110%29.aspx> 

Pertinent to your case it could be written as:

```
DateTime.Now.ToString("M-d-yyyy", DateTimeFormatInfo.InvariantInfo);

```

Regards,
You can use the `.ToString()` method on the `DateTime` object to format it however you'd like. Your code would look something like this: 

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

More info on formatting date times can be found on the MSDN: <http://msdn.microsoft.com/en-us/library/zdtaw1bw%28v=vs.110%29.aspx>