Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 1
    You should use NicoESIEA's answer if you care about DST (which you should) Commented Mar 26, 2021 at 16:23
  • 3
    This by far is the most elegant solution to the problem because it takes care of the fact that it handles the nasty situation of setting days beyond that of the month. You could literally right the function like...function addTime(years, month, day). If you want to go crazy with it you could add the hours, minutes, seconds and the milliseconds. I used to do it a lot in Unity for keeping track of the time in game because it used the Epoch method. Commented Jul 13, 2021 at 17:16