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.

Customising the CMS /

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

Admin displays date field year 1 year behind


Go to End
Reply


3 Posts   920 Views

Avatar
Media Contour

Community Member, 33 Posts

18 September 2011 at 9:51am

I have a page type in the admin with a date field. When I enter a date in the admin for example September 8, 1994 it displays correctly in the front end but when i refresh the admin the date displays as Septemeber 8, 1993 one year behind. Any suggestions as to why this is happening?

ArticlePage.php

<?php

class ArticlePage extends Page {
	static $db = array(
		'Date' => 'Date',
		'Time' => 'Time'
	);
	
	static $has_one = array('ArticleAuthor' => 'Author');
	
	static $has_many = array('ArticleImages' => 'ArticleImage');
	
	function getCMSFields() {
		$fields = parent::getCMSFields();
		
		$fields->addFieldToTab('Root.Content.Main', $dateField = new DateField('Date','Article Date (for example: 12/12/2011)'), 'Content');
    		$dateField->setConfig('showcalendar', true);
		    $dateField->setConfig('dateformat', 'MM/dd/YYYY');
	   $fields->addFieldToTab('Root.Content.Main', $timeField = new TimeField('Time','Article Time (for example: 00:00:00)'), 'Content');
		    $timeField->setConfig('showdropdown', true);
		
		$articleimages = new ImageDataObjectManager(
			$this,
			'ArticleImages',
			'ArticleImage',
			'Image',
			array(
				'Name' => 'Name',
				'Caption' => 'Caption'
			),
			'getCMSFields_forPopup'
		);
		$fields->addFieldToTab('Root.Content.ArticleImages', new LiteralField('Article Images Break', '<br />'));
		$fields->addFieldToTab('Root.Content.ArticleImages', new LabelField('Article Images Label', 'Article Images'));
		$fields->addFieldToTab('Root.Content.ArticleImages', $articleimages);
		
		$author = new HasOneDataObjectManager(
			$this,
			'ArticleAuthor',
			'Author',
			array(
				'FirstName' => 'FirstName',
				'MiddleName' => 'MiddleName',
				'LastName' => 'LastName',
				'Link' => 'Link'
			),
			'getCMSFields_forPopup'
		);
		$fields->addFieldToTab('Root.Content.Author', new LiteralField('Article Author Break', '<br />'));
		$fields->addFieldToTab('Root.Content.Author', new LabelField('Article Author', 'Article Author'));
		$fields->addFieldToTab('Root.Content.Author', $author);
		
		return $fields;
	}
}

class ArticlePage_Controller extends Page_Controller {}

?>

Avatar
Pipifix

Community Member, 56 Posts

12 July 2012 at 9:23pm

Hello.

I got the same strange behavior. Did you get this problem solved?

Avatar
martimiz

Forum Moderator, 1199 Posts

14 July 2012 at 3:19am

I don't know if this is the same thing but I remember running into something like that once, where it helped using yyyy instead of YYYY. I can still reproduce it - but in my case only for the first of januari :-)