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
Post a Comment