Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Can't write a ssdatetime value...

Go to End

4 Posts   3225 Views


Community Member, 70 Posts

12 May 2009 at 12:07am

Hi folks,

I'm trying to run a function every so often instead of every time a page is called (it's parsing an xml feed that can't take very many hits per hour), but can't get one part of it working.

I've got a value of LastUpdated, am testing against that to the current time -3 hours, running the XML parser function, then saving the current time as the LastUpdated value.

Problem is it doesn't save the LastUpdated value and I'm at a loss to know what's going on! The LastUpdated value is a SSDatetime if that makes any difference?

// in the class
public static $db = array (
            'LastUpdated' => 'SSDatetime'

// in the controller
public function getEntries() {
            // call $this->updateEntries() if this holder has not been updated in the last 3 hours
            if(strtotime($this->LastUpdated) < strtotime('-3 hours')) {
                $this->LastUpdated = date("Y-m-d H:i:s",time());


Community Member, 2 Posts

21 May 2009 at 2:56pm

I had the same problem. Adding

public static $casting = array(
  "LastUpdated" => "SSDatetime"

in the class, after the field definition, helped.


Community Member, 176 Posts

23 May 2015 at 9:25pm

Settings $casting variable didn't help in my SS3.1 version, ended up fixing it by manually setting value in onBeforeWrite
public function onBeforeWrite() {
// Fix SS_Datetime not writing issue
$this->DateTimeout = strtotime(str_replace("/", "-", $this->DateTimeout["date"]) . " " . $this->DateTimeout["time"]);


Community Member, 419 Posts

25 May 2015 at 2:53am

Edited: 25/05/2015 2:55am

Well, for the first two lads at least, if you're using 3.1+ then you want private static $config_val