The literary and historical evidence clearly points to a date during the reign of Antiochus IV Epiphanes when the book was finalized, sometime between the installation of the Abomination of Desolation in the Temple (on Chislev 25, 168 BC) and Antiochus' death in the spring of 164 BC (which did not occur according to the scenario foreseen by the author of the Hebrew apocalypse, ch. 8-12). One big question is whether the book was published prior to the removal of the Abomination of Desolation (exactly three lunar years after its installation, i.e. on Chislev 25, 165 BC), or in the months between its removal and Antiochus' death. The book correctly predicts the restoration of the Temple in approximately the correct length of time (3 1/2 years instead of 3), which was something that Josephus found impressive. Chapter 8 is specifically concerned with the duration of time when the Tamid offerings are interrupted and the sancutary is defiled, and it suggests that the duration is 1,150 days (reckoning the duration as the total number of Tamid offerings skipped, with one given in the morning and one in the evening), which is about 70 days longer than three schematic years. Since the myarch Apollonius' assault on Jerusalem occurred a few months before the heathen altar was installed in the Temple, it is possible that the Tamid offerings had stopped sometime prior to the installation of the heathen altar.
Chapter 8 is a commentary on ch. 7 and interprets the "little horn" of the fourth kingdom (Greece), here clearly revealed to be Antiochus Epiphanes; the question about the duration ("how long?") in ch. 8 was then treated to a lengthier explication in ch. 9. I am persuaded by the reconstruction of the book's evolution by Albertz and other scholars, which regards the book as a composite (which explains its unusual linguistic and literary features). The original nucleus of the book was a collection of stories about the Babylonian exile revolving around Daniel and his friends. These stories originally circulated in oral form (as ch. 3 clearly shows evidence of orality) but were eventually committed to writing in the fourth and third centuries BC. The literary form of the stories varied considerably from place to place. An early collection of ch. 4-6 arose in the middle of the third century BC which survives in the OG LXX; these chapters in the LXX are clearly independent versions of the same stories in the Aramaic but do not derive directly from the Aramaic (and they have a Tendenz reflecting the situation of the Jews in Egypt). Sometime at the end of the third century BC during the reign of Antiochus III, a similar collection of stories appeared in Aramaic: this supplemented the core in ch. 4-6 (a succession narrative) with the two martyr stories in ch. 3 and 6. There were other stories about Daniel that did not make it into this collection (such as the story of Bel, or the story of Susanna, or the story of the dragon), but which were later incorporated into the Greek versions of the book. Then during the Fifth Syrian War (between 202 and 195 BC), the Aramaic apocalypse of Daniel was completed with the addition of the visionary narratives in ch. 2 and 7 (the outermost layer to the Aramaic book). At this time there was an apocalyptic movement in Judea (also mentioned in the Animal Apocalypse) that encouraged "those violent among the people to rebel in order to fulfill the vision" (Daniel 11:14), but the author of the Aramaic apocalypse objected to this claiming that God himself would intervene to put an end to the current war and the hegemony of Greece (which would be replaced with God's kingdom), it would occur "not by human hand". Then during the reign of Antiochus IV Epiphanes, the Hebrew apocalypse (ch. 8-12) was added to the Aramaic collection (this was written in the first person). First the vision in ch. 7 was interpolated to include the figure of the "little horn", which gave rise to the pesher in ch. 8 that described in further detail the fall of Greece and the actions of the "little horn", particularly with respect to his desolation of the Temple. Then ch. 9 gives a fuller explanation of why the Temple was desolated so long after the end of the Babylonian exile, and exactly when the current desolation would come to an end. Then ch. 10-12 gave a parallel explication of Hellenistic history from the time of Alexander the Great to the present (165-164 BC), foreseeing a third campaign by Antiochus against Egypt which never occurred, and his death on Judean soil which never occurred. (Nor did the resurrection of the dead follow this as well) The book was completed with the addition of ch. 1 to the Aramaic apocalypse, which gave a proper introduction in Hebrew to the book, and the awkward splice between Hebrew and Aramaic is still visible at 2:4b. There are certainly other ways to analyze the compositional history of the book, but this is the one that makes the most sense to me.
It must be recalled that the book itself claims to have been published in the 160s BC. The book uses a common literary device to explain why no one had heretofore seen such a writing that supposedly had been written in the sixth century BC. The putative author, the prophet Daniel, seals up the scroll and the book goes into hiding until the "time of the end". Then when its message needs to be read by the people of a later time centuries later, the book is discovered and "unsealed", allowing its message to reach its intended audience. This same device of the hidden book occurs very commonly in apocalyptic and other literature. The Assumption of Moses claims that it is one of the books that Moses deposited in a secret place in earthenware jars, to be revealed when the "day of recompense" draws near (1:16-18). Similarly, the Damascus Document suggests that the Temple Scroll (11QTemple) is another sealed book of the Law that was kept inside the Ark of the Covenant and was unknown to David, and which would not be "revealed until the sons of Zadok [i.e. the Essenes] arose" (5:1). The book of Revelation actually explicitly rejects this trope by saying that it was NOT to be sealed up, for the message was intended for the first-century readers of the book (not readers centuries later), as the events prophesied in the book were about to "shortly take place" (22:10, 20). So Daniel is told in 8:26 "to keep the vision secret" and we read in 12:4, 9: "You, Daniel, must keep these words secret and the book sealed until the time of the end....These words are to remain secret and sealed until the time of the end". Notice that this isn't talking about a sealing of the true understanding of the book (as the Society explains the verse), it is the book itself that is sealed up. Of course, the book of Daniel is now no longer hidden and the author elsewhere indicates in ch. 8-11 that he believed that the Maccabean crisis of the 160s BC was the "time of the end". This means that it was around 168-164 BC when the Hebrew apocalypse appeared seemingly out of nowhere and circulated publically among the people. The book itself explains that the reason why no one had earlier seen this work is that it had been "sealed up" and "kept secret" until that time.