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.

Customising the CMS /

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

setConfig("dateformat","dd/MM/Y") produces wrong Dates on the 1.January of every Year


Go to End


2 Posts   2538 Views

Avatar
Matze0681

Community Member, 25 Posts

10 June 2010 at 6:02pm

Hi,

i got a strange problem when formating Dates with setConfig("dateformat" ,....) It always substracts one Year of the given DateValue.
For example:
if the saved date is 01/01/2010 it will display as 01/01/2009
if the date is 01/01/2011 it will display as 01/01/2010 and so on...

$date1 = new DateField('RangeEnd','Range End',$this->RangeStartDate);
$date1->setConfig("dateformat","dd/MM/Y");

is that a bug or a feature ? ;) Or did i do something wrong ?

thanks in advance

Avatar
Matze0681

Community Member, 25 Posts

11 June 2010 at 10:12am

just solved it. If there is somebody who got the same issue:

setConfig('dateformat','dd/MM/y') produces the correct Year value

and

setConfig('dateformat','dd/MM/Y') produces a wrong Year