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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

Dates showing as 1969! Please help!


Go to End


10 Posts   5362 Views

Avatar
Blackdog

Community Member, 156 Posts

9 October 2008 at 4:33pm

Edited: 09/10/2008 4:36pm

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.

Avatar
Phalkunz

Community Member, 69 Posts

9 October 2008 at 6:34pm

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

Go to Top