Jump to:

3448 Posts in 1062 Topics by 738 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Can't write a ssdatetime value...

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

Page: 1
Go to End
Author Topic: 2139 Views
  • LesC
    Community Member
    70 Posts

    Can't write a ssdatetime value... Link to this post

    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());

  • ilyabr
    Community Member
    2 Posts

    Re: Can't write a ssdatetime value... Link to this post

    I had the same problem. Adding

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

    in the class, after the field definition, helped.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.