I am using the following format to convert a DateTime to a string
setting.SettingValue = dt.ToString( "yyyy-MM-dd HH:mm:ss.fff" );
however the value is not as expected. The SettingValue
property contains this value
2014-01-07 23.14.59.000
which uses a different time separator (.
) instead of the specified one (:
)
Any help?
You haven't specified a format provider, so it's using the one from the current culture. If you always want to use :
, you should specify an appropriate provider, e.g.:
setting.SettingValue = dt.ToString("yyyy-MM-dd HH:mm:ss.fff",
CultureInfo.InvariantCulture);
See more on this question at Stackoverflow