Solved! iTunes Play Date Tag Numeric Mystery

February 16, 2021

The meaning and background of the iTunes Play Date tag

About 10 years ago, I embarked on a project to parse the contents of the hulking XML file that iTunes creates to hold all the metadata about the music I listen to. There's a ton of interesting info buried in there about my listening habits. Interesting to me, at any rate.

For instance, I created a script that lists all the music I've listened to for the past month. The little program is almost automatic--I just have to load the updated XML file to the server once a month. Now I have 15 years of this nearly useless information. Want to know what I was jamming August 25, 2007, driving out I-80 west to Burning Man? The answer's in there somewhere.

And this project is where I learned how to decode the nine-digit "Play Date" tag, and how the format follows a tradition that goes all the way back to the birth of the Apple Macintosh itself.

The "XML Music Library.xml" file, which resides on the computer you dock your iPhone to, offers two tags that capture at what time a mp3 track was played, "Play Date," and "Play Date UTC."

<key>Play Date</key><integer>3365245919</integer>
<key>Play Date UTC</key><date>2010-08-21T18:31:59Z</date>

"Play Date UTC" is in human-parsable form (UTC stands for, somewhat counter intuitively, Coordinated Universal Time).

"Play Date," on the other hand, is a nine-digit integer.

I was curious as to if I could calculate the time played directly from "Play Date" tag, rather than parse the "Play Date UTC" tag apart. I suspected that iTunes stored this number for exactly such purposes, in fact.

The challenge was to decipher the number. A "Play Date" value of "3365245919" should equal "2010-08-21T18:31:59," to use the example above. I would just need to find the conversion algorithm.

My first guess was that it was a Unix Timestamp, given that iTunes, in its original Macintosh incarnation, ran on Unix. The Unix Timestamp counts time in terms of seconds elapsed since January 1, 1970.

When I put the number "3365245919" into a Unix Timestamp calculator, I didn't get August 21, 2010 at all, but rather Aug 21, 2076!! Crazy!

My next guess was to inspect the "Play Date" number a bit. By comparing a few "Play Date" and "Play Date UTC" entries, I confirmed that the incrementation was, in fact, in seconds: One song played at 3:10 has the "Play Date" of "3365248245" while the next song, played at 3:13, had a "Play Date" of "3365248408," which was greater by 163-- or just under three minutes if you consider a second for each increment.

So, August 21, 2010, 6:31.59 was 3,365,245,919 seconds ahead of what date? A quick consult with the online Epoch Converter, 3,365,245,919 seconds equals 38,949 days (and 14 hours and 31 minutes).

Punch this number into the ole online date calculator (the Internet remains undefeated!), we find that subtracting 38,949 days from August 21, 2010 brings us to January 1, 1904.

So, in short, the iTunes "Play Date" figure is the number of seconds that have elapsed since January 1, 1904.

In other words, Apple is using an Epoch time, a time series with an arbitrary start point. In this case, the developers of iTunes decided on January 1, 1904.

And this is keeping with an Apple tradition. This date is the official starting point for all Macintosh computer timestamps. Apple chose January 1, 1904, because it was the last century's first leap year-- which would make it an easy starting point for developers. (as to why 1900 wasn't a leap year, check this article here).

So everything is cool, at least until 2040, when Apple's Epoch time runs out of digits and turns over. Will you be ready?