Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-08-14 08:31:26

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

I want to use 'Publish dates' before 1970 but get errors…

When I try to use a date before 1970 in ‘Publish dates’ in an article, I get the following error:

Invalid publish date or time.

Is there any way to use publication dates before 1970?


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#2 2019-08-14 10:22:44

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: I want to use 'Publish dates' before 1970 but get errors…

Sadly, only in custom fields. Txp’s Posted date is subject to testing against the earliest UNIX epoch of Jan 1st 1970.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2019-08-14 10:46:41

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: I want to use 'Publish dates' before 1970 but get errors…

Bloke wrote #319039:

Sadly, only in custom fields. Txp’s Posted date is subject to testing against the earliest UNIX epoch of Jan 1st 1970.

Oh, that’s too bad!

Thanks for the feedback, Bloke.


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#4 2019-08-14 10:55:12

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: I want to use 'Publish dates' before 1970 but get errors…

It’s annoying. Any dates prior to 1970 get set to 0 when converted to a UNIX timestamp so if you’re making dates before that, you should deal with them directly and not rely on the timestamp.

PHP supports such dates. MySQL supports them with DATETIME. UNIX timestamps do not (unless they’re signed, which I believe most systems don’t do, and only gives you a limited backwards range anyway).

If we could design out the reliance on timestamps (in PHP) and TIMESTAMP columns (in MySQL) in future and just manipulate dates directly using the DateTime() object, we could support any dates back as far as year 1000. I’d like to do that one day if possible.

EDIT

Txp only uses TIMESTAMP columns in two places:

  1. In txp_lang to hold the last-modified date of the language. That’s fine as it’s never going to need to be before 1970.
  2. In the upcoming txp_meta table for custom fields, because I’m a tool. They should be DATETIME. I’ll fix that if and when we decide whether to support timed custom field visibility. It still creates usability headaches, so I’m deciding whether to drop that feature.

The upshot is we only need to design out our use of UNIX timestamps in PHP and use of UNIX_TIMESTAMP() in MySQL (if we can) one day to support the fullest range of dates possible.

Last edited by Bloke (2019-08-14 11:06:21)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2019-08-14 11:04:21

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: I want to use 'Publish dates' before 1970 but get errors…

Bloke wrote #319045:

It’s annoying. Any dates prior to 1970 get set to 0 when converted to a UNIX timestamp so if you’re making dates before that, you should deal with them directly and not rely on the timestamp.

PHP supports such dates. MySQL supports them with DATETIME. UNIX timestamps do not (unless they’re signed, which I believe most systems don’t do, and only gives you a limited backwards range anyway).

If we could design out the reliance on timestamps (in PHP) and TIMESTAMP columns (in MySQL) in future and just manipulate dates directly using the DateTime() object, we could support any dates back as far as year 1000. I’d like to do that one day if possible.

That would be great.

Any site working with history in some way will want to have dates before 1970…


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#6 2019-08-14 15:22:07

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: I want to use 'Publish dates' before 1970 but get errors…

Bloke wrote #319045:

The upshot is we only need to design out our use of UNIX timestamps in PHP and use of UNIX_TIMESTAMP() in MySQL (if we can) one day to support the fullest range of dates possible.

I guess timestamps are there because of potentially different MySQL/PHP servers timezones. Wish there were an easier way of timezones conversion…

Offline

#7 2019-08-14 16:15:07

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: I want to use 'Publish dates' before 1970 but get errors…

etc wrote #319060:

I guess timestamps are there because of potentially different MySQL/PHP servers timezones.

Yes. That and the fact we don’t store all relevant information in our database tables to permit accurate conversion. We store dates that have been ‘corrected’ for server location. We should be storing DateTime + UTC timezone offsets in separate columns so correct dates can be reconstructed at any point in time regardless of DST/timezone.

This even covers us if a site moves server location. I do this every now and again by moving from one Euro server to another when I rebuild sites. Since that might be in a different timezone, it invalidates all stored datestamps so articles appear to have been posted at different times to when they actually were. In my case it’s not much of an issue, but for an events-based site using year/month/day URLs, that potentially means URLs become invalid, or events show as occuring on different days/times than they’re published :\

There are a bunch of GitHub issues to do with this somewhere. It’s a big job but it needs doing one day.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2019-08-15 03:17:49

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 446
Website

Re: I want to use 'Publish dates' before 1970 but get errors…

Bloke wrote #319062:

Yes. That and the fact we don’t store all relevant information in our database tables to permit accurate conversion. We store dates that have been ‘corrected’ for server location. We should be storing DateTime + UTC timezone offsets in separate columns so correct dates can be reconstructed at any point in time regardless of DST/timezone.

This even covers us if a site moves server location. I do this every now and again by moving from one Euro server to another when I rebuild sites. Since that might be in a different timezone, it invalidates all stored datestamps so articles appear to have been posted at different times to when they actually were. In my case it’s not much of an issue, but for an events-based site using year/month/day URLs, that potentially means URLs become invalid, or events show as occuring on different days/times than they’re published :\

There are a bunch of GitHub issues to do with this somewhere. It’s a big job but it needs doing one day.

I hadn’t even considered events-based sites. Interesting, how a simple question exposes such big issues…


Old Photos of Japan – Japan in the 1850s~1960s (100% txp)
MeijiShowa – Stock photos of Japan in the 1850s~1960s (100% txp)
JapaneseStreets.com – Japanese street fashion (mostly txp)

Offline

#9 2019-08-15 10:32:51

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: I want to use 'Publish dates' before 1970 but get errors…

Kjeld wrote #319064:

I hadn’t even considered events-based sites. Interesting, how a simple question exposes such big issues…

Uhhh yeah, sorry for derailing the thread.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB