Converting a year from 4 digit to 2 digit and back again in C#
- by Mike Wills
My credit card processor requires I send a two-digit year from the credit card expiration date. Here is how I a currently processing:
I put a DropDownList of the 4-digit year on the page.
I validate the expiration date in a DateTime field to be sure that the expiration date being passed to the CC processor isn't expired.
I send a two-digit year to the CC processor (as required). I do this via a substring of the value from the year DDL.
Is there a method out there to convert a four-digit year to a two-digit year. I am not seeing anything on the DateTime object. Or should I just keep processing it as I am?