I have a custom post type called books. The books publication date is from between 1700 and 1900.

I want to set the post date to these dates(so i can query the results sorted by year) but i can't seem to have a date set before 1970 january 1.

Is it possible to somehow do that?

  • As far as I can tell the post date is capped at 1902.
    – Wyck
    Jan 5, 2013 at 21:26
  • I took a look at this and the post_date in the database sets correctly to any date I tried. However, post_date_gmt is set incorrectly as Jan. 1, 1970-- the beginning of the world. So don't try to coopt that field. Do what toscho suggests.
    – s_ha_dum
    Jan 5, 2013 at 21:30
  • +1 nice Question! Searching for 1970 has interesting results here and at SO. The plugin doesn't seem very well coded, but may be worth a look...
    – brasofilo
    Jan 5, 2013 at 21:34

2 Answers 2


Do not use the post_date field for anything it isn’t made for. Use a post meta field instead. The post_date is bound to post_date_gmt, you would get strange side effect even you could get an earlier date into that.

So create post meta fields and query those per tax query. Ignore the default field.

In answer to your comment: Do not use a taxonomy.

  1. Taxonomies are build to allow multiple terms per post (ignore post-formats here). The scheme does not match your use case.
  2. Taxonomy queries are expensive, they run through three tables.
  3. You would have to change the default interface to prevent accidents like multiple assignments. Possible, but not exactly simple and maybe not forward-compatible.

I started a book manager plugin once too, unfortunately it is still in a draft status … but I have some recommendations regarding dates:

  1. Use two post types: one for the opus, one for the real editions (the opus type would be a parent for multiple editions). So you can store the creation date in the opus, the publication date (the language, the editor, translator and so on) in the edition.

  2. Read Making <time> safe for historians. Dates before 1970 are hard.

  3. The MySQL Date and Time Functions cannot handle all cases, you end up with some custom routines for sorting, depending on your solution for (2.).

  • Thanks! My client sent me an xml file with the books and i imported that into wordpress. I only have the years for the books so i decided to create a custom taxonomy for the years, but then i found out that i can't order the query based on this. But if i can order by custom field, then i guess its fine that way too.
    – passatgt
    Jan 5, 2013 at 21:35
  • Let me ask you, what do you think, is it a good enough solution to use a custom taxonomy for the years? I think i can create a custom sql query to sort the results based on the term name(because the db structure is basically the same with the post meta solution too) and i think its a little easier to manage the years+books in the backend.
    – passatgt
    Jan 5, 2013 at 21:46
  • @passatgt See my update. Short: no, don’t do that. :)
    – fuxia
    Jan 5, 2013 at 21:53
  • Got it. Worth to mention though, that i have 25.000 books:)
    – passatgt
    Jan 5, 2013 at 22:12

This plugin uses the ADOdb Date Library by John Lim of PHP Everywhere, which is -- I quote -- "making date formatting with dates before 1970 a charm".

  • That plugin does more that the OP is asking for and it isn't clear if it the date formatting is used internally by the plugin or if it also enables the same date formatting for WordPress core functions. Do you know the answers to any of those questions?
    – s_ha_dum
    Jan 8, 2013 at 22:45
  • I just wanted to highlight Lim's library, and how it's implemented in a WP plugin. As to your second question, core functions are not altered, the plugin stores the dates in a custom database table.
    – diggy
    Jan 9, 2013 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.