c# - Convert date from ajax post in controller to yyyyMMdd -
I get some dates in the string in the AJAX post to the controller.
code Modify public performance Partnering organization (Guide partner id, string alias name, string effective date, string end date) {partner partner = new partner (); Partner.PartnerId = partnerID; Partner.ExternalId = Alias name; Partner. Effective Date = Date Time Paras eXact (Effective Date, "YYMEMMD"), Culture Info Invoireticulture, Datetime Style. Non); Partner End date = date time Purse Axact (Expiry date, "Yemenammed", Culture Info. Inventions, Datetime Style. }
The date coming from the customer side
MM-DD-YYYY format for example
01/10/2014 (Explanation for adding 01 only In) / Oct / 2014) as the controller 10/1/2014
while trying to parse this error. The
string was not recognized as a valid date time.
Any help on this?
OK, the client obtained from the format is mm / dd / yyyy . You should parse that way, such as yyyyMMdd :
datetime. Purse Ecact (Effective Date, "MM / DD / Yay", Culture Infoc. Inventoryticulture, Datetime Style.); Also note the use of MM instead of MM , because mm is a minute, not months .
All formats you have so far specified:
string effective date = "01/10/2014"; String Effective Date2 = "30 / oct / 2014"; String effectdate 3 = "1/10/2014"; DateTimeD = DateTime Purse Axact (Effective Date, "MM / DD / Yay", Culture Info. Inventive Culture, Datetime Style. Non); DateTime = D2 = DateTime Purse Axact (Effective DAT 2, "DD / MMM / Yay", Culture Info. Inventions, Daytime Style Non.); DateTime3 = DateTime Purse Exact (Effective Date 3, "D / MM / Yay", Culture Info. Inventions, Datetime, a.);
Comments
Post a Comment