The Bible is a compilation of various texts or "books" of different ages.
The dates of many of the texts of the Hebrew Bible (or Old Testament) are difficult to establish. Textual criticism places all of them within the 1st millennium BCE/BC, although there is considerable uncertainty as to the century in some cases. According to one version of the documentary hypothesis the Torah was redacted into its final five-books form around 450 BCE/BC, using elements from as early as 1000 BCE/BC. The Nevi'im and Ketuvim were partly compiled in the 6th century BCE/BC from 8th- and 7th-century BCE/BC materials, then expanded in the post-exilic period from the 5th to 2nd centuries BCE/BC. With the exception of extensive manuscripts and fragments found among the Dead Sea scrolls, no Hebrew Bible manuscript predates the 2nd century BCE/BC.
The individual books of the New Testament may be dated with some confidence to the 1st and 2nd centuries CE/AD. The earliest fragment of the New Testament is the Rylands Library Papyrus P52, a piece of the Gospel of John dated to the first half of the 2nd century. For this reason, dating the composition of the texts relies on textual criticism, philological and linguistic evidence, as well as direct references to historical events in the texts instead of dating the physical manuscripts.
The Hebrew Bible
The authorship of the various texts in Tanakh (the Hebrew Bible) is an open topic of research. Therefore, assigning solid dates to any of the texts is difficult.
The range of dates assigned to the Torah (Pentateuch) is rather broad. It is certain to predate the 2nd century BCE/BC, but some estimates of its oldest elements range from the 10th to the 6th centuries BCE/BC. The bulk of the Tanakh was likely complete by the end of the Babylonian captivity (537 BCE/BC) and had probably reached its fixed Masoretic form by the 4th century BCE/BC. The text had certainly become fixed by the 1st century BCE/BC and the completion of the Septuagint.
Some groups of people, e.g. the Lubavitch Jewish community, insist that the whole of the Torah was dictated by the Almighty, and written down by Moses, on Mount Sinai.
Some critical scholars (the 'Biblical Minimalists"), however, insist that the whole of the Torah shows evidence of its construction composed after 538 BCE/BC, perhaps with material from an earlier oral tradition, as it were, a "prequel" to the prophetic books.
Others, such as archeologist Israel Finkelstein, tend to suggest that a substantial portion of the Pentateuch is a 7th century BCE/BC construction, designed to promote the dynastic ambitions of King Josiah of Judah. The 6th century BCE/BC Books of Kings tells of the rediscovery of an old book by King Josiah, which would be the oldest part of the Torah, around which Josiah's scribes would have fabricated the remaining text:
And Hilkiah the high priest said unto Shaphan the scribe, I have found the book of the law in the house of the LORD. And Hilkiah gave the book to Shaphan, and he read it. (2 Kings 22:8 KJV)
Under Josiah's rule there would then for the first time have been a unified and state of Judah, centralized around the worship of Yahweh based at the Temple in Jerusalem, with texts portraying King Josiah as the legitimate successor to the legendary David and thus the rightful ruler of Judah. According to this interpretation, neighboring countries that kept many written records, such as Egypt, Persia, etc., have no writings about the stories of the Bible or its main characters before 650 BCE/BC, and the archaeological record of pre-Josiac Israel does not support the existence of a unified state in the time of David. However, this view is challenged by references to the "House of David" and Davidic Kings of Israel in 9th century BCE/BC inscriptions. 
A traditional strain of scholarship[who?] would assign portions of the Pentateuch (generally, the J author) to the period of the United Monarchy in the 10th century BCE/BC, would date Deuteronomy and the Deuteronomic history to the time of King Josiah, and that the final form of the Torah was due to a redactor in exilic or postexilic times (6th century BCE/BC). This view is based on the account of the finding of the "book of law" in 2 Kings 22:8, which would correspond to the core of Deuteronomy, and the remaining parts of the Torah would have been composed to supply a background from traditional accounts to the rediscovered text.
The "book of the chronicles of the kings of Judah" (14:29; 15:7, 23, etc.)
The "book of the chronicles of the kings of Israel" (14:19; 15:31; 16:14, 20, 27, etc.).
The date of its composition was perhaps some time between 561 BCE/BC, the date of the last chapter (2 Kings 25), when Jehoiachin was released from captivity by Evil-merodach, and 538 BCE/BC, the date of the decree of deliverance by Cyrus the Great.
The Book of Isaiah, in its present form, is by most scholars considered the result of an extensive editing process, in which the promises of God's salvation are reinterpreted and claimed for the Judean people through the history of their exile and return to the land of Judah. Very few scholars dispute these conclusions and argue for the unity of the composition of the book. When the Septuagint version was made (about 250 BCE/BC), the entire contents of the book were ascribed to Isaiah, the son of Amoz. In the time of Jesus, the book existed in its present form, with many prophecies in the disputed portions quoted in the New Testament as the words of Isaiah.
Traditionally, the Book of Daniel was believed to have been written by its namesake during and shortly after the Babylonian exile in the 6th century BCE/BC. However, most mainstream scholars find this view to be untenable in light of both archaeology and textual analysis. Scholarship on the dating of the Book of Daniel largely falls into two camps: one dates the book in its entirety to a single author during the desecration of the Jerusalem Temple (167–164 BCE/BC) under the Syrian-Greek ruler Antiochus IV Epiphanes (ruled 175–164 BCE/BC); the other sees it as a collection of stories dating from different times throughout the Hellenistic period (with some of the material possibly going back to very late Persian period), with the visions in chapters 7–12 having been added during the desecration of Antiochus. For example, Hartman and Di Lella, 1978 suggest multiple authorship, with some material dating to the 3rd century, culminating with a 2nd-century editor and redactor.
The reasons for these dates include a use of Greek and Persian words in the Hebrew of the text unlikely to happen in the 6th century, that the style of the Hebrew and Aramaic was more like that of a later date, that the use of the word "Chaldean" occurs in a fashion unknown to the 6th century, and that repeated historical gaffes betray an ignorance of the facts of the 6th century that a high official in Babylon would not have, while the 2nd-century history was found to be far more accurate (see Ferrell Till's analysis).
John Collins, on the other hand, finds it impossible for the "court tales" portion of Daniel to have been written in 2nd century BCE/BC because of textual analysis. In his 1992 Anchor Bible Dictionary entry for the Book of Daniel, he states, "it is clear that the court-tales in chapters 1–6 were 'not written in Maccabean times'. It is not even possible to isolate a single verse which betrays an editorial insertion from that period."
during or shortly after the period of the Maccabees
The oldest known preserved fragment of a Torah text is a good luck charm inscribed with a text close to, although not identical with, the Priestly Blessing found in Num 6:24–27, dated to approximately 600 BCE/BC  The oldest complete or nearly complete texts are found in the Dead Sea Scrolls from the middle of the 2nd century BCE/BC to the 1st century CE/AD. The collections contain all the books of the Tanakh except for the Book of Esther, although not all are complete.
According to tradition the Torah was translated into Greek (the Septuagint, or LXX, from the traditional number of translators) in the 3rd century BCE/BC. The oldest Greek manuscripts include 2nd century BC fragments of Leviticus and Deuteronomy and 1st century BCE/BC fragments of Genesis, Exodus, Leviticus, Numbers, Deuteronomy, and the Minor Prophets. Relatively complete manuscripts of the Septuagint include the Codex Vaticanus and the Codex Sinaiticus of the 4th century and the Codex Alexandrinus of the 5th century—these are the oldest surviving nearly-complete manuscripts of the Old Testament in any language.
Additional manuscripts include the Samaritan Torah and the Peshitta, the latter a translation of the Christian Bible into Syriac, the earliest known copy of which dates to the 2nd century CE/AD.
The New Testament
The most accepted historical understanding of how the Synoptic gospels developed is known as the two-source hypothesis. This theory holds that Mark is the oldest gospel.
Matthew and Luke are believed to come later, and draw on Mark and also on a source that is now believed to be lost, called the Q document, or just "Q". Some scholars reject the two-source hypothesis and say it suffers from a number of weaknesses in terms of historicity and textual issues. 
Traditional views assume that the bulk of New Testament texts date to the period between 45 CE/AD and 95 CE/AD, with the Pauline epistles among the earliest texts. Other views may pre- or post-date the individual books by several decades. The earliest preserved fragment for each text is included as well.
The Nag Hammadi library, a collection of books found in 1945, some refer to as Gnostic Scriptures (which include the Gospel of Thomas), were not accepted as canonical by the early orthodox Christian communities. They were written in Coptic and are generally dated to the 3rd and 4th centuries CE/AD, though the Gospel of Thomas has ignited some debate. The majority of New Testament scholars and historians place composition no earlier than the 2nd century whereas a minority argue dates as early as the 60's.
Many of the scholars who hold conservative views believe that Torah was written from the mid to late 15th century BCE/BC, on the basis of 1 Kings 6:1. Similarly, they say, the book of Isaiah in its entirety was written by Isaiah himself (as stated in Isaiah 1:1), and that the book of Daniel was written by the court official who lived and worked from the time of Nebuchadnezzar to the first year of Cyrus. Where events and people are mentioned before they happened or were born, they are explained as evidences of God's ability to tell the future in his communication with mankind.
The first three Gospels, Acts, Paul's Epistles, Hebrews, James, and Peter's Epistles were written in the period between about 50–65 CE/AD.
The Gospel of John, John's Epistles, Jude, and Revelation were written between about 85–100 CE/AD.
John A. T. Robinson argued that the entire New Testament was written before 70 CE/AD. "One of the oddest facts about the New Testament is that what on any showing would appear to be the single most datable and climactic event of the period - the fall of Jerusalem in 70 CE/AD, and with it the collapse of institutional Judaism based on the temple - is never once mentioned as a past fact."
↑Richard E. Friedman, Who Wrote the Bible? has 1000 BCE/BC to 950 BCE/BC for J.
↑Such claims are detailed in Who Were the Early Israelites? by William G. Dever (William B. Eerdmans Publishing Co., Grand Rapids, MI, 2003). Another such book is The Bible Unearthed by Neil A. Silberman and Israel Finkelstein (Simon and Schuster, New York, 2001).
↑"'David' Found at Dan," Biblical Archaeology Review, March-April 1994