Somebody should check whether ISO 8601 says that the separator has to be - or --. (iso.org/iso/home/standards/iso8601.htm). Definitely YYYY/MM/DD should not be used - that would violate the standard. Keith
– KeithBJan 8 '14 at 9:53

sorry but I do not see how this package is useful. It seems to force you to manually enter the date values, which it then formats.... so why not just manually write them yourself in the correct format in the document? What is this accomplishing? This answer does not actually show how to use the datetime2 to solve the problem in the question.
– user5359531Aug 31 '17 at 2:22

3

The package option should be style=iso, but a numeric YYYY-MM-DD style is the default anyway, so it's not needed.
– Nicola TalbotJun 7 '18 at 11:30

1

@user5359531 \documentclass{article}\usepackage{datetime2}\begin{document}\today\end{document} is a basic MWE that prints the current date as YYYY-MM-DD style. As for specific dates, the syntax is \DTMdate{2018-06-07} but the formatting depends on the style. So while it does just display 2018-06-07 for the default style, if you change the style it will display the date in a different format.
– Nicola TalbotJun 7 '18 at 11:34

It can print dates, advance them by numbers of days, weeks, or months,
determine the weekday automatically, and print them in (mostly)
arbitrary format. It can also print calendars (monthly and yearly)
automatically, and can be easily localized for non-English languages.

Welcome to TeX.SX! This does not really answer the question and would probably be more appropriate as a comment. (You need 50 reputation to comment, however.) Also, I think you meant \ifnum#1>99 instead of \ifnum#1>100.
– CircumscribeJun 7 '18 at 10:39