0

I have two applications (web site and desktop application) launched on the one machine, both uses the following to serialize DateTime object value:

string strDateTileFullFormat = Thread.CurrentThread.CurrentCulture
    .GetConsoleFallbackUICulture().DateTimeFormat.FullDateTimePattern;

string SummarySupporyUntil = string.Concat("until ",
     TestLicenseExpiryDate.ToString(strDateTileFullFormat));

One application create: "Saturday, December 31, 2011 12:00:00 AM", another: "December 31, 2011 12:00:00 AM"

Difference is that one uses "Canada" country setting, another - "USA".

The problem is that I need these date to be similar (actually, I don't know which kind is correct, perhaps the 1st one).

I looked web/app.config files but don't see anything related to locale settings. Also, I don't have manual changes for CurrentCulture...

Please advise. Thanks!

Budda
  • 18,015
  • 33
  • 124
  • 206
  • Does the serialization format itself have any standard format for datetime (as is the case with XML for instance)? If so, it could be a good idea to settle for that format. If not, consider using some other standard instead of a local format, such as [ISO-8601](http://en.wikipedia.org/wiki/ISO_8601). – Fredrik Mörk Dec 15 '10 at 21:43

1 Answers1

0

Once you have decided which culture suits you best, you can use System.DateTime's powerful formatting features as stated in the doc: DateTime.ToString Method with a fixed culture:

For example with en-US culture (1033):

string SummarySupporyUntil = string.Concat("until ",
     TestLicenseExpiryDate.ToString(strDateTileFullFormat, new Culture(1033)));

will give the same result on every machine it will be ran.

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298