Dave James Miller's Blog

Smarty, WinSCP and Timezone issues

So, daylight savings time started a few days ago, and suddenly some problems that I had with Smarty last summer are back. Last time I was relatively new to Smarty, so I blamed Smarty itself… This time I know better.

The problem

When I modify a template, the old (compiled) version was being displayed, instead of it being recompiled automatically. (I resorted to deleting the contents of the templates_c/ directory each time!)

The culprit

Today I noticed that the timestamp of the compiled files in templates_c/ was an hour in the future in WinSCP. But when I checked using SSH, they were correct on the server, and the template files were an hour behind.

It turns out WinSCP was incorrectly adding an extra hour to all timestamps. But this wasn’t just affecting what it displays – whenever it uploaded a file, it would subtract an hour from the timestamp to compensate. So Smarty would not know the template had been updated, and so would not recompile it.

The solution

Edit the saved session, and in the Environment section is a Daylight saving time box. Change it from “Adjust remote timestamp to local conventions (Unix)” to “Preserve remote timestamp (Unix)”. Save the session and reconnect.

n.b. An alternate is to go to View > Preferences > Transfer and uncheck “Preserve timestamp”. (Although it’ll still show incorrect times in the file list.)

Posted on 1st April 2009. 3 comments.

Comments

1. Paul

Thanks for publishing this! I was in the process of debugging Smarty, but coincidentally found out that the problem didn’t occur when editing directly from the host machine.

Your post saved me bunches of time; thanks again!

Posted on 6th May 2010 at 11:35pm.

2. Shahmir Noorani

Thanks for this. I had narrowed down the culprit to either WinSCP or notepad++ and this helped out immensely.

Posted on 17th June 2010 at 7:48pm.

3. YAY

Dude you rock for this

Posted on 18th June 2011 at 12:33pm.

Add a Comment