Languages
[Edit]
EN

C# / .NET - add year to DateTime

7 points
Created by:
Marcino
720

In C# / .NET it is possible to add years to date in following way.

DateTime.AddYears method example

Edit

Output:

Notes: 
  • time has been printed in console according to iso 8601 standard - check this link for more details.
  • DateTime.AddYears allows to subtract years by typing negative numbers as argument.

References

Edit
  1. DateTime.AddYears Method - Microsoft Docs
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

C# - DateTime

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join