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?
Do not use the
post_date
field for anything it isnât made for. Use a post meta field instead. Thepost_date
is bound topost_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.
I started a book manager plugin once too, unfortunately it is still in a draft status ⦠but I have some recommendations regarding dates:
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.Read Making
<time>
safe for historians. Dates before 1970 are hard.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.).
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”.