WordPress.org

Ready to get started?Download WordPress

Forums

Gripe against PHP dates prior to 1969 (23 posts)

  1. pezastic
    Member
    Posted 9 years ago #

    The PHP time limitation.

    Am I alone in this gripe? Am I the only one over the age of 36 using WP and/or wanting to timestamp an entry or two prior to 1969?

    Someone referenced a possible hack solution here, but didn't expound upon it:

    http://wordpress.org/support/topic.php?id=5802

    Does anyone have a way around this limitation?

  2. dherren
    Member
    Posted 9 years ago #

    I can't speak for others, but I certainly have no need for blogging software, designed to make publishing current daily thoughts and ideas relatively easy, to be capable of posting things back in the 60's when blogs and microcomputers didn't exist, nor can I imagine why anyone would want to read posts allegedly posted at such a time.

  3. TechGnome
    Moderator
    Posted 9 years ago #

    pezastic - First of all, it isn't a limitation of WP, so don't knock it for that. It's a limitation of php, because time is based off of the time elapsed singe the Unix Epoch (Jan 1, 1970)

    dherren - I've done posts like. Back dated them to my birthday. It's about events or about me back at that time. There's nothing wrong with it, it's simply a limitation of the language used. I've heard of workarounds but haven't had the need to explore it, so I'm not sure what they are.

    However, if you check the documention for dates & time in PHP: http://www.php.net/manual/en/ref.datetime.php You might be able to find someone who had the same problem and (hopefully) left a comment with a solution.

    Tg

  4. Root
    Member
    Posted 9 years ago #

    Don't you just love that UNIX epoch stuff.? :)

  5. RyanBrooks
    Member
    Posted 9 years ago #

    I seem to remember a plugin for changing the timestamp to whatever date was wanted... oi.

  6. pezastic
    Member
    Posted 9 years ago #

    RyanBrooks - I would certainly like to find that plugin. Please try to remember where you saw it.

    dherren - I didn't know that WordPress was "designed to make publishing current daily thoughts and ideas". I thought the purposes for it, being what it is, are limited only by one's imagination. No?

    TechGnome - I know that it isn't a WordPress limitation, hence the citing of "PHP time limitation" in my first post on this thread. However, I do have a gripe against WP and all other CMSes that are developed under PHP, because they knowingly limited themselves from having any ability to include posts prior to 1969, as if nobody would ever need that kind of cataloging ability. (And that link you sent me on gave me a headache, but thanks for trying.)

    It isn't just a problem of making journal entries appear pre-1969. What if someone wanted to use WordPress for writing movie reviews for movies older than 1969, or someone wanted to present the diary of a famous person who lived before 1969, or someone wanted to catalogue items in their museum or gallery that were older than 1969, or...?

    Wanna end my gripe? Give me a solution to this problem. If I could write the code, I would. But, I couldn't code myself out of a paper box. I am at the mercy of those who are in-the-know.

    Now, it doesn't hurt to ask, does it?

  7. TechGnome
    Moderator
    Posted 9 years ago #

    Solution is simple. Find something else.

    Tg

  8. TechGnome
    Moderator
    Posted 9 years ago #

    aaah... let me expand on that a little. WP is a tool. You have to use the right tool for the right job. In this case, it doesn't sound like a good fit. Ergo, a different tool needs to be selected.

    Tg

  9. Kafkaesqui

    Posted 9 years ago #

    Or you could start throwing some money around. I've seen that help move solutions along...

  10. pezastic
    Member
    Posted 9 years ago #

    I don't want to find another app. I'm happy with WordPress, except for this little thing. There was a solution presented here:

    http://wordpress.org/support/topic.php?id=21918#post-137506

    But, I didn't understand it. Can someone take a look at that post and tell me how to do that?

  11. Anson-Parker
    Member
    Posted 9 years ago #

    wordpress could do a lot more with a fix in the mktime / gmmktime usage - use the workaround on win_gmmktime is a fix on the php site and may work. stickin' it in the function.php in the include directory.. if anyone else has tried this holla
    peace

  12. MaryE
    Member
    Posted 9 years ago #

    OK, let's see if I can explain what I did. I have not looked into whether this affects security or has other side-code affects, but I have not experienced any myself.

    I've explained (poorly it seems) on other posts about using the adodb libraries to get around the UNIX epoch. The overview on the download page explains its functionality pretty well.

    1. Be very careful, this is base code! Back up all files and database before trying!

    2. Download the "adodb Date Time Library" at http://phplens.com/phpeverywhere/adodb_date_library
    It is a zip file.

    3. Unzip this file. Inside you will see 1 file called "adodb-time.inc.php". This is a php file you will put in a base include directory and reference as an include file from the appropriate php files.

    4. Move the file "adodb-time.inc.php" into the "wp-includes" folder of your wordpress installation. Now you will modify the files in this folder that use the date/time functions. The main file that does this is the file "functions.php". That contains the main time formatting and conversion functions. In this file, the following functions need to be changed:

    mktime(...) becomes adodb_mktime(...)
    date(...) becomes adodb_date(...)
    gmdate(...) becomes adodb_gmdate(...)

    There are about 15 lines in this file that need to be changed. [The elipses (...) mean don't change the parameters].

    5. Add a line at the top (around line 3) of the "functions.php" file - to include the "adodb-time.inc.php" file, after the <php> tag:

    require_once(dirname(__FILE__).'/adodb-time.inc.php');

    You can add this right under the other line that starts with "require_once".

    6. You can repeat items 4 and 5 for other files that use the date/time functions. Another file is the one that does the calendar function - 'template-funcitons-general.php'.

    7. Be very careful, this is base code! Did I metion that you should back up all files and your database before trying?

  13. copperleaf
    Member
    Posted 9 years ago #

    I've looked at this library too (not for posts but for timestamping photos which can definitely be prior to 1970.) I'm wondering if the licenses clash. WP is GPL and the adodb license is "[...] released under BSD-style license [...]". Unfortunately he's not clear on whether it's the old style or new style bsd license. My understanding is that the old style (original) was not compatible with GPL which is stated in the GPL faq.

  14. Kafkaesqui

    Posted 9 years ago #

    adodb is released under a dual license: BSD and LGPL, and the LGPL makes it compatible.

  15. jimturner
    Member
    Posted 8 years ago #

    MaryE, your hack did the trick! Thanks a ton for the instructions!!!

  16. Waldo Jaquith
    Member
    Posted 8 years ago #

    What a happy coincidence that this thread would be revived today.

    I run WordPress on a half dozen different sites, and I'm looking start a new one. It will reproduce historical journals from the 1800s, one day at a time, in a blog format. Of course, the necessary date format is not supported. I was about to whip up my own software, but I figured a quick check of the WordPress forums was in order.

    I haven't tried Mary's solution yet, but I look forward to doing so.

  17. MaryE
    Member
    Posted 8 years ago #

    Glad someone else could use (test) this change. One area I have not fully investigated is whether the RSS feeds aggregate/order properly on these dates. That would be a nice way to tie together historical logs across multiple sites.

    M.

  18. tedinoz
    Member
    Posted 7 years ago #

    Thanks MaryE.

    Just wanted to say that I found this thread and MaryE's hack in June/July 2006. But I was a lurker at that stage.

    In my case, I had 3,600 posts dated between 1788 and present, so a solution was absolutely necessary.

    MaryE's description is terrific - detailed, accurate & succinct. If you have this problem you should not hesitate to use this hack.

    I have upgraded once before (2.0.4) and again today to 2.0.5; each time I get out my copy of MaryE's notes and work my way through. Yes, it does take a little longer, but it is a small price to pay if you want this functionality.

    Thanks

    Ted

  19. GhostPressBed
    Member
    Posted 7 years ago #

    absolutely amazing. brilliant. genius even. stupid unix epoch. thank you very much MaryE.

  20. MaryE
    Member
    Posted 7 years ago #

    Gee, I should read this forum more often (thanks for giving me bragging rights to my teenage kid). I'd love to see some examples in the wild, I've just been experimenting with reseach my husband's been doing. Any urls for viewing?

    Other things I'd like to do, let me know if there's interest ... candidates for WP plugins, perhaps?

    1. make a timeline along the design of blogtimes
    2. do something with circa dating - in general, be able to set granlarity of date entry and display
    3. deal with Julian vs. Gregorian dating - possibly tieing to country codes or geourl? - low priority but annoying 'cause I know it's there as a "gap".

    While I've been using a variety of tools for my websites, I keep coming back to WP as a very simple but powerful tool to get the job done.

    The latest version of another open source CMS has introduced an extension for adodb date libraries. But by the time I get everything set up just the way I want it (particularly getting the taxonomy modules in line with the date settings), I've gotten bored with the whole thing. So KUDOS to WP for keeping it simple!!

  21. vkaryl
    Member
    Posted 7 years ago #

    MaryE: this is a sorta "stay tuned" thing.... couple of those plugin ideas might be things I'd have a use for.... and give me a bit, I'll be using the "fix the stupid unix epoch" tweak on a blog (where I'll need dates in FR parlance - so that'll be fun n different!).

    I'll post back here eventually....

  22. tedinoz
    Member
    Posted 7 years ago #

    Hi MaryE

    An example in the wild? No worries.
    http://www.navyhistory.org.au/?p=4537
    This is my "earliest" post, it's dated 5 February 1788.
    If you follow the post's "date-range" type category, you'll see quite a few others.

    The post titles (groan) are another problem altogether and we're working on that.

    FWIW, I'm just playing with permalinks and am bumping up against the 1970 issue again. So if your proposed permalink looks like index/Y/M/D/postname, then the earliest date for Y=1970 AND it spits the dummy - BIG TIME. Not sure whether this is a PHP or Apache issue.

    Anyway, thanks again MaryE
    Ted

  23. MaryE
    Member
    Posted 7 years ago #

    Nice site. I don't know the specifics of your problem, but I did notice more had to change in 2.03, and the permalinks needed extra attention. From my experience, the following files to be changed:

    * functions.php
    * functions-formatting.php
    * template-functions-general.php
    * template-functions-link.php

    The templating functions seem to be a new twist. I only include adodb_time.inc into functions.php, which are included in the other 3 files.

    The permalinks require a 2 line change to replace strtodate() with code used in other functions elsewhere in WP.

    More specifically, in file template-functions-links there is the following code around line 53:

    $unixtime = strtotime($post->post_date);
    $category = '';
    if ( strstr($permalink, '%category%') ) {
    $cats = get_the_category($post->ID);
    $category = $cats[0]->category_nicename;
    if ( $parent=$cats[0]->category_parent )
    $category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
    }
    $authordata = get_userdata($post->post_author);
    $author = $authordata->user_nicename;
    $date = explode(" ",date('Y m d H i s', $unixtime));

    Looking at the first and last line in this fragment -- you will be changing these:

    First line to change:
    $unixtime = strtotime($post->post_date);

    ==> change this to the following 2 lines (or it can be 1 line if you don't like the $m variable):

    $m = $post->post_date;
    $fulltime = adodb_mktime(substr($m,11,2), substr($m,14,2), substr($m,17,2),substr($m,5,2), substr($m,8,2), substr($m,0,4));

    Second line to change:
    $date = explode(" ",date('Y m d H i s', $unixtime));

    ==> change this to the following 1 line:

    $date = explode(" ",adodb_date('Y m d H i s', $fulltime));

    -----------------------------------------

    Don't know if this solves your problem, but it was definitely a problem for me. Usual disclaimers, base code, back everything up, etc., etc. Also I did a quick eyeballing of the differences, if this and changes in the other 3 files don't do the trick, I can do a diff on the codebase.

    M.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags