Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-07-08 14:17:19

husainhk
Member
From: Dubai, UAE
Registered: 2007-08-12
Posts: 105
Website

Article Timestamps and Backdating Multiple Articles

Hi All,

I just moved my local MAMP site to Dreamhost and saw that all the articles posted had a future timestamp when I imported the database on Dreamhost.

Is this because of the remote server’s date/time settings? I now have to resave all 100+ articles :( Is there a way to backdate all articles in one go?

Thanks in advance.

Cheers,
Husain

Last edited by husainhk (2008-07-08 14:18:05)

Offline

#2 2008-07-08 15:45:00

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Article Timestamps and Backdating Multiple Articles

Is the time-zone preference set correctly?
Are the difference between the old and the new dates the same for all articles?

Offline

#3 2008-12-09 01:34:39

hcgtv
Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Re: Article Timestamps and Backdating Multiple Articles

I just ran into this, as I’m moving my local sites up to Dreamhost. My local server was set to EST, Dreamhost is set to PST.

It appears that all my article dates are 3 hours in advance, those that were in the database prior to the import. Any new articles I create, they have the proper date, so my time settings are cool. I have my Time Zone at -5.00, DST = no. If I set the Time Zone to -8.00, then my old articles display the right time but anything new I enter assumes I’m living in California.

What to do, I can’t afford to move my family in these troubled times across the country ;)

Offline

#4 2008-12-10 14:33:28

hcgtv
Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Re: Article Timestamps and Backdating Multiple Articles

Reading up on this on the Dreamhost wiki, the Google and a confirmation from tech support, there is no way to change the timezone for a whole domain since PHP is run as a CGI.

PHP can’t inherit .htaccess changes like:
SetEnv TZ America/New_York

So the only thing to do is add this to your PHP script:
date_default_timezone_set(‘America/New_York’);

Where would be the best place to add this in the Textpattern core files?

Offline

#5 2008-12-12 18:57:16

hcgtv
Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Re: Article Timestamps and Backdating Multiple Articles

hcgtv wrote:

So the only thing to do is add this to your PHP script:
date_default_timezone_set(‘America/New_York’);

Where would be the best place to add this in the Textpattern core files?

I take it the only alternative I have is to run a SQL query to change the dates in the database?

http://sam.brown.tc/entry/262/textpattern-urls-are-broken-txp-gods-help

Offline

#6 2008-12-15 21:51:16

danwoodward
Member
From: Brooklyn NY
Registered: 2006-08-06
Posts: 51
Website

Re: Article Timestamps and Backdating Multiple Articles

This worked for me

@UPDATE textpattern SET Posted = CURRENT_TIMESTAMP()@

If you’re still confused, you put that line of code in your phpMyAdmin database

(x_x)

Last edited by MR. (2009-01-09 07:04:57)

Offline

#7 2008-12-16 13:07:35

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Article Timestamps and Backdating Multiple Articles

^^ wouldn’t that reset all Posted dates to the current date?

Offline

#8 2008-12-16 14:54:31

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: Article Timestamps and Backdating Multiple Articles

ruud wrote:

^^ wouldn’t that reset all Posted dates to the current date?

which would also mean that newer/older would not work?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#9 2008-12-16 14:54:51

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: Article Timestamps and Backdating Multiple Articles

ruud wrote:

^^ wouldn’t that reset all Posted dates to the current date?

which would also mean that newer/older would not work?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#10 2008-12-17 19:50:36

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Article Timestamps and Backdating Multiple Articles

yes and yes.

Offline

#11 2008-12-17 19:58:15

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Article Timestamps and Backdating Multiple Articles

Backup first. Then try:

UPDATE textpattern SET Posted = DATE_SUB(Posted, INTERVAL 3 HOUR) WHERE Posted < 2008-12-10 00:00:00;

This should set the Posted date back 3 hours for all articles posted before december 12th 2008.
To go in the opposite direction (setting Posted forward in time), use DATE_ADD instead of DATE_SUB.

Last edited by ruud (2008-12-17 19:58:24)

Offline

#12 2008-12-17 21:58:13

hcgtv
Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Re: Article Timestamps and Backdating Multiple Articles

ruud wrote:

This should set the Posted date back 3 hours for all articles posted before december 12th 2008.

I had just gotten down to this todo item, and I was checking the forum.

It worked just fine, I used:

UPDATE textpattern SET Posted = DATE_SUB(Posted, INTERVAL 3 HOUR)

When I made the switch to the new server, I started entering dates 3 hours ahead of EST, thinking that a query would fix it all later.

Thanks Ruud.

Offline

Board footer

Powered by FluxBB