asp.net mvc - Parsing text to return date -


i have textbox can add age {a} y {b} m {c} w y=years, m=months, w=weeks , submit button , want return parsed birth date according age expression.

for example want 2y 1 m / 2 yr 1 mon return 2013/09/27. (the difference today , parsed date)

how can in asp.mvc? every approach ok...using c#, javascript...

thank you!

so first create view model

view model

public class viewmodel {     public int years { get; set; }     public int months { get; set; }     public int weeks { get; set; } } 

then on view pass in using @model viewmodel @ top.

then once have submitted sort of form can following:

public datetime calcuate() {     var result = datetime.utcnow;      result = result.addyears(viewmodel.years*-1).addmonths(viewmodel.months*-1).adddays(viewmodel.weeks*-7);     return result; } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -