Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Dates showing as 1969! Please help!

Our old forums are still available as a read-only archive.

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

Page: 1 2
Go to End
Author Topic: 3748 Views
  • Blackdog
    Avatar
    Community Member
    156 Posts

    Re: Dates showing as 1969! Please help! Link to this post

    You might find Date as a field name is a clash with a mysql reserved word.

    try using

    "PostDate" => "Date"

    $fields->addFieldToTab('Root.Content.Main', new CalendarDateField(PostDate, 'Date'), 'Content');

    the do a flush and see if it works.. remember to change the $Date to $PostDate in your template.

  • Phalkunz
    Avatar
    69 Posts

    Re: Dates showing as 1969! Please help! Link to this post

    It looks all good to me. Anyways, try

    new CalendarDateField('Date')

    instead of

    new CalendarDateField('Date', 'Date')

    and populate the default using the following code:

    public function populateDefaults(){
       parent::populateDefaults();
       $this->Date = date("Y-m-d H:i:s",time());
    }

    3748 Views
Page: 1 2
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.