2

How to get CurrectCulture and force converting and converting back a DateTime in this culture. I have tried

var myDate = DateTime.Parse(myDate , CultureInfo.InvariantCulture); 

but it does't work. then I suppose that I must specify the CurrentCulture.

Ehsan
  • 31,833
  • 6
  • 56
  • 65
Sam
  • 97
  • 10

2 Answers2

1

Try This:

 var myDate = DateTime.Parse(myDate, CultureInfo.CurrentCulture); 
Sudhakar Tillapudi
  • 25,935
  • 5
  • 37
  • 67
0

Use this CultureInfo.CurrentCulture Property represents the culture used by the current thread.

var myDate = DateTime.Parse(myDate , CultureInfo.CurrentCulture); 
Nagaraj S
  • 13,316
  • 6
  • 32
  • 53
  • Could you explain why you're not using `CurrentUICulture`? – Thorsten Dittmar Mar 18 '14 at 09:21
  • @ThorstenDittmar any difference between them – Nagaraj S Mar 18 '14 at 09:24
  • As far as I understand there actually could be. One is the info "that represents the current user interface culture used by the Resource Manager to look up culture-specific resources at run time", the other "represents the culture used by the current thread". I wonder when to use which. – Thorsten Dittmar Mar 18 '14 at 09:28
  • @ThorstenDittmar i think here `CurrentUICulture` would be fine, i am right?? – Nagaraj S Mar 18 '14 at 09:33
  • I don't know! I am asking you as I am really interested. I'd probably have used `CurrentUICulture` for display as it would be coherent with the other resources, but I seriously don't know! – Thorsten Dittmar Mar 18 '14 at 09:51