Gripe against PHP dates prior to 1969
-
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:
https://www.ads-software.com/support/topic.php?id=5802
Does anyone have a way around this limitation?
-
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.
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: https://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
Don’t you just love that UNIX epoch stuff.? ??
I seem to remember a plugin for changing the timestamp to whatever date was wanted… oi.
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?
Solution is simple. Find something else.
Tg
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
Or you could start throwing some money around. I’ve seen that help move solutions along…
I don’t want to find another app. I’m happy with WordPress, except for this little thing. There was a solution presented here:
https://www.ads-software.com/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?
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
peaceOK, 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 https://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?
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.
adodb is released under a dual license: BSD and LGPL, and the LGPL makes it compatible.
MaryE, your hack did the trick! Thanks a ton for the instructions!!!
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.
- The topic ‘Gripe against PHP dates prior to 1969’ is closed to new replies.