If you're creating a DateTime object using the expiration dates (month/year), you can use ToString() on your DateTime variable like so:DateTime expirationDate = new DateTime(2008, 1, 31); // random datestring lastTwoDigitsOfYear = expirationDate.ToString("yy");如果在验证期间使用DateTime对象,请注意日期.如果有人选择05/2008作为卡的失效日期,则失效日期为5月底,而不是第一天. Be careful with your dates though if you use the DateTime object during validation. If somebody selects 05/2008 as their card's expiration date, it expires at the end of May, not on the first. 这篇关于将年份从4位数转换为2位数,然后在C#中再次返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-30 18:51