Skip to content
Loading
how to solve date string not in correct format
  • DateTime validityDate = DateTime.ParseExact(txtValidity.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
     
    in this line getting error on 'CultureInfo'
  • MN Ambaliya
    Hi, please try this.
     
    This is more accurate
     
    DateTime validityDate = DateTime.ParseExact(txtValidity.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
  • hello
     
    where i place this code in my code when i place this
     
    obj.Validity =Convert.ToDateTime(txtValidity.Text).ToString("dd/MM/yyyy");
      
    i am getting error
     
    it not work error is not valid date time
  • MN Ambaliya
    This is the another solution.
     
    DateTime validityDate = DateTime.ParseExact(txtValidity.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); 
  • MN Ambaliya
    Please try this.
     
    Convert.ToDateTime(txtValidity.Text).ToString("dd/MM/yyyy")
     
    Please mark as answer if it helps.