Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-03-10 15:46:50

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Article timestamp quirk

Hi. This is a fun one for a Sunday.
I have a site that’s misbehaving a little. Briefly, newly-created article timestamps are moved forward one hour when I hit Publish. Also, the article is being marked with a ‘Last updated:’ timestamp (<txp:modified /> when it technically hasn’t been.

I recorded it in a screencast so you can see what I mean: http://www.youtube.com/watch?v=Mgt7KP_Kqqk (work safe).

Low-detail diagnostics with some .htaccess redirect stuff removed for brevity:

Textpattern version: 4.5.4 (r4919)
Last update: 2012-12-05 10:42:44/2012-12-05 10:42:19
Document root: /var/www/vhosts/petecooper.org/httpdocs
$path_to_site: /var/www/vhosts/petecooper.org/httpdocs
Textpattern path: /var/www/vhosts/petecooper.org/httpdocs/textpattern
Permanent link mode: section_title
Temporary directory path: /var/www/vhosts/petecooper.org/httpdocs/.tmp
Site URL: petecooper.org
PHP version: 5.3.5
GD Graphics Library: bundled (2.0.34 compatible); supported formats: GIF, JPG, PNG.
Server TZ: UTC
Server local time: 2013-03-10 15:46:21
DST enabled?: 1
Automatically adjust DST setting?: 1
Time zone: America/Los_Angeles (-28800)
MySQL: 5.1.54-log
Locale: en_GB.UTF-8
Server: Apache
Apache version: Apache
PHP server API: apache2handler
RFC 2616 headers: 
Server OS: Linux 2.6.18-028stab101.1
Active plugins: soo_modified-0.1.0, arc_pref_override-0.1, csb_if_newer_than-1.0, rah_replace-0.4, smd_countdown-0.1, zem_contact_lang-4.0.3.6, zem_contact_reborn-4.0.3.20, aks_var-0.3, smd_query-0.50, rah_sitemap-1.2m, zem_article_info-0.2, rvm_css-0.9.1, upm_textile_toggle-0.5
Admin-side theme: classic 4.5.4

.htaccess file contents: 
------------------------
#DirectoryIndex index.php index.html

#Options +FollowSymLinks
#Options -Indexes
#ErrorDocument 403 default

<IfModule mod_rewrite.c>
	RewriteEngine On
	#RewriteBase /relative/web/path/

	RewriteCond %{REQUEST_FILENAME} -f [OR]
	RewriteCond %{REQUEST_FILENAME} -d
	RewriteRule ^(.+) - [PT,L]

	RewriteCond %{REQUEST_URI} !=/favicon.ico
	RewriteRule ^(.*) index.php

	RewriteCond %{HTTP:Authorization}  !^$
	RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

#php_value register_globals 0

# SVG
AddType image/svg+xml  svg svgz
AddEncoding gzip       svgz

<IfModule mod_gzip.c>
	AddOutputFilterByType DEFLATE text/plain
	AddOutputFilterByType DEFLATE text/html
	AddOutputFilterByType DEFLATE text/xml
	AddOutputFilterByType DEFLATE text/css
	AddOutputFilterByType DEFLATE application/xml
	AddOutputFilterByType DEFLATE application/xhtml+xml
	AddOutputFilterByType DEFLATE application/rss+xml
	AddOutputFilterByType DEFLATE application/javascript
	AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>

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

I know that DST has kicked in in the last day or two, but does that affect the <txp:posted /> date in the way it has? Any and all suggestions/pointers are most welcome. Thank you in advance.

Last edited by gaekwad (2013-03-10 16:02:11)

Offline

#2 2013-03-10 17:02:36

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Article timestamp quirk

Yes it does. Displayed dates are formatted according the timezone settings you set from the Preference panel. The preferences and DST do affect already set dates too. Saved dates are not attached to a specific timezone, but float with configuration changes, reporting the date in the current timezone. The preferences basically try to save a date in a known base timezone and then calculate the formatted date from that.

Which in theory works fine… but there are errors in Textpattern’s time and date handling. You can find stuff about if you search these forums. All the existing issue reports still apply to this day.

One of the issues is that the timestamps that are saved with articles are handled by the database server and not by the application, Textpattern. The visible dates on the other are formatted according the application server and Textpattern’s preferences. There also are differences in timestamp comparison and check operations (DB vs. application, current timezone vs. UTC, date – timezone offset vs. actual UTC).

This means that if your database server and the application server (Textpattern) are using different timezones or for some reason configurations change, or clocks are set to different times, you will get errors. Like this one. Saved date is the one database server is using, while the formatting is done according the application. The results? Freaking odd dates.

You can try to aid this by playing with the time/date settings and making sure timezone settings are correct for the server. So that the application and database agree.

But are there errors in timezone handling and date/time saving? Yes. Absolutely. All dates should be handled by one party. Either DB or the application, and the dates should contain the timezone that was used at the time (or URLs should strictly use UTC).

Last edited by Gocom (2013-03-10 17:18:01)

Offline

#3 2013-03-10 17:30:21

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Re: Article timestamp quirk

Thanks, Jukka – that’s very useful information.

Offline

Board footer

Powered by FluxBB