Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Instead of using the <code>Convert.ToDateTime</code> method you can use the <code>DateTime.Parse</code> or <code>DateTime.ParseExact</code> methods. Both allow you to pass a culture that tells how you expect the date to be formatted.</p> <p>The <code>DateTime.ParseExact</code> method also allows you to specify the format you expect, so you can parse more or less any format with this method. </p> <p><strong>Edit:</strong><br> Regarding <code>Convert.ToDateTime</code>. The documentation says that the current culture is used when parsing: <a href="http://msdn.microsoft.com/en-us/library/xhz1w05e.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/xhz1w05e.aspx</a> </p> <p>The current culture can be found using the <code>System.Threading.Thread.CurrentThread.CurrentCulture</code> property. </p> <p><strong>Edit2:</strong><br> Oh. You may also want to use <code>DateTime.TryParse</code> and <code>DateTime.TryParseExact</code> if you are unsure whether the given format is invalid.</p> <p><strong>Edit3:</strong><br> Lots of edits here... I see that you want to determine the culture string that matches the date the user has entered. There is no general solution that is guaranteed to work here. Say for instance that the user has entered the date 01.02.11. There is no way to be certain if this date is in day.month.year or month.day.year or year.month.day and so on.</p> <p>The best you can do is to have a list of expected input cultures and start with the most likely and try to parse the date using that. If that fails, you can try the second most likely and so on... </p> <p>But this is really not recommended. Either give the user an expected format, or better, use a date input box that ensures that you receive the selected date in an appropriate format.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload