Take the 2-minute tour ×

When specifying a date format for the jQuery UI datepicker YY is a 4 digit year and Y is a 2 digit year:

YY = 2011 Y = 11

See http://docs.jquery.com/UI/Datepicker/formatDate

Was curious why this is.

share|improve this question

closed as not constructive by Second Rikudo, Andomar, David Thomas, PHeiberg, mu is too short Dec 31 '11 at 0:33


You'd probably want to ask them. –  Second Rikudo Dec 30 '11 at 22:24
While I've offered an answer to this question I'm also voting to close as 'not constructive' since it solicits opinion, and without someone from the jQuery datepicker team answering the question, speculation and opinion is all we can offer. –  David Thomas Dec 30 '11 at 22:26

2 Answers 2

up vote 5 down vote accepted

All of the single character variations (d, m, y) are the short version. Double is long version. Since the short version of a year is two digits, using yy specifies the long version, which is four digits. The format is not directly related to the number of digits that the date outputs. Just as M (single) means: "Jan, Feb, Mar, Apr", and MM (double) means: "January, February, March, April". The same goes for all of the format chars.

This is unlike the standard format for PHP, which may confuse some.

The chosen format was to meet the web standards (RFC)s for date formatting.

See: RFC-822

share|improve this answer
Which web-standards RFCs? Often I have seen "YYYY" as the long form and "YY" as the short form, although I could see an argument -- for symmetry -- against this, as per the post. Dates like IOS8601 are actually defined in terms YYYY for the 4-digit year (or +-YYYYY extended). –  user166390 Dec 30 '11 at 22:38
Source: ietf.org/rfc/rfc822.txt –  Highway of Life Dec 30 '11 at 22:46
In RFC822, the only thing I can find is a "Military Date" (or Little-endian form date): DD MON YY, where YY is only two digits. While still common for [web server] log files, I wouldn't consider it a modern [1982] web-standard. ISO8601, and the small common subset of it, is much less ambiguous and variants thereof are used most systems... in any case, the question is about choosing YY/Y instead of YYYY/YY to designate the format, and I can see merit with the argument for why it was chosen (so +1). However, I do not agree with the rest :) –  user166390 Dec 31 '11 at 0:04
Okay, unfortunately, more things use RFC822 than that ... I being slightly facetious about it not being a "current standard". In any case, RFC822 only specifies a 2-digit year and is otherwise not related to the the YY/Y question. In RFC822, date = 1*2DIGIT month 2DIGIT ; e.g. 20 Jun 82. –  user166390 Dec 31 '11 at 0:12

Presumably because they wanted to keep things such as option/variable names brief; in this usage it seems clear that Y indicates the short-form, whereas YY clearly indicates the long-form, of the date format.

share|improve this answer
