Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-07-15 11:52:17

geoff777
Plugin Author
From: Benarrabá Andalucía Spain
Registered: 2008-02-19
Posts: 282
Website

Today's Articles - Time-zone Problem

Hi

I’ve run into a problem trying to list today’s articles.

The txp_textpattern table field POSTED has the server time stamp and not my local time which is +09:00 different.

So article_custom month=“yyyy-mm-dd” isn’t producing the results I want.

Any ideas how to solve this problem.

Also shouldn’t the field POSTED use my local time?

Thanks
Geoff


There are 10 types of people in the world: those who understand binary, and those who don’t.

Offline

#2 2010-07-15 16:11:36

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Today's Articles - Time-zone Problem

Dumb question, but did you check your time zone settings in preferences?

Offline

#3 2010-07-15 18:37:26

geoff777
Plugin Author
From: Benarrabá Andalucía Spain
Registered: 2008-02-19
Posts: 282
Website

Re: Today's Articles - Time-zone Problem

Hi Els

Yes set to my local time. Madrid – Spain. auto DST enabled.

Server is somewhere in the US I believe -09:00 behind.

Are you saying the POSTED field should contain LOCAL time and not my SERVER time?

Thanks Geoff

It’s never been an issue I just list the x most recent .. not by a precise date .. until today.

Last edited by geoff777 (2010-07-15 18:46:18)


There are 10 types of people in the world: those who understand binary, and those who don’t.

Offline

#4 2010-07-15 22:00:36

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Today's Articles - Time-zone Problem

geoff777 wrote:

Are you saying the POSTED field should contain LOCAL time and not my SERVER time?

Yes, of course it should contain your local time. I suppose you didn’t move the site to this server recently? Unfortunately I don’t really know how to troubleshoot this. Just a couple of things I would check:

If you open the Write tab, is the timestamp displaying your local time or the server time?
Does it make a difference if you publish an article with ‘Set timestap to now’ checked or unchecked?
Once published, is the correct timestamp displayed below the excerpt?

(I will also move this topic to the Troubleshooting forum, hoping that people who can help you will notice it there.)

Offline

#5 2010-07-15 22:31:31

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

Re: Today's Articles - Time-zone Problem

geoff777 wrote:

Are you saying the POSTED field should contain LOCAL time and not my SERVER time?

I think there’s some confusion here. From memory, the timestamp in the database is always stored with the server offset applied.

If you look at the database with phpMyAdmin you’ll notice that your article timestamps are 9 hours behind your local time. But when you use the txp:posted/modified/expires/etc tags, the offset that has been stored in the database is removed so the actual time (also taking DST into account) is displayed. Thus the posted tag shows local time, but the posted field in the database houses server-offset-adjusted time. And, before you ask, sorry but I have no idea why!

This poses at least three problems:

  1. As you found, when you try to use the month attribute in article_custom
  2. When you use year-month-day permlinks because you can find that articles posted, say, at 7am on the 15th July actually get a URL site.com/2010-07-14 even though the article itself (the txp:posted tag) will display the correct date. To further confound things, if you visit site.com/2010-07-15 you get a 404 error
  3. If your hosting company moves location all your timestamps in the database will still have the original offset applied, but the new server will advertise its current offset so any txp:posted/modified/expires tags will show the wrong date

I’m sure there are more. fwiw, this is not just a TXP issue, it’s common to a lot of CMSs (I believe WP suffers here too, but I don’t have any recent evidence to support this).

Short answer is I don’t know a simple fix right now. Saccade, among others, have gone to great lengths around the forum to talk about this phenomenon and it’s worth reading up on it just to see how far the rabbit hole goes. A lot of solutions have also been suggested but, to date, I think all of the potential long-term fixes have had serious backwards-compatibility issues, such as forcing you to resave every article or some such headache.

But it’s been a while since I looked at all this so I may be totally off-base here, what with the new timezone options in 4.2.0 and the new timezone support in PHP 5.1.0+. All I know is that it plagues things like smd_calendar (which was buggy to begin with) and I still haven’t found a satisfactory answer in that plugin either. If anybody has some fresh ideas here I’d love to hear them.

Last edited by Bloke (2010-07-15 22:35:54)


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

#6 2010-07-15 22:52:09

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Today's Articles - Time-zone Problem

Bloke wrote:

Thus the posted tag shows local time, but the posted field in the database houses server-offset-adjusted time.

Sorry Geoff, I didn’t read your post well enough and thought you meant the date and time fields in the write tab… Apologies for the confusion! And thanks for pointing it out Stef :)

Last edited by els (2010-07-15 22:52:54)

Offline

#7 2010-07-16 18:10:15

geoff777
Plugin Author
From: Benarrabá Andalucía Spain
Registered: 2008-02-19
Posts: 282
Website

Re: Today's Articles - Time-zone Problem

Els wrote:

Sorry Geoff, I didn’t read your post well enough and thought you meant the date and time fields in the write tab… Apologies for the confusion! And thanks for pointing it out Stef :)

No problem Els, and as usual many thanks to Bloke for a full explanation.

I’m sure there’s a way round it .. it was just a silly whim to list the posts that I ‘d published today or the last 24 hours.

Not really necessary .. I thought it would be easy using article_custom.

I can live without this.

It’s an interesting quirk rather than a major problem.

Thanks to you both
Geoff


There are 10 types of people in the world: those who understand binary, and those who don’t.

Offline

Board footer

Powered by FluxBB