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.

Data Model Questions /

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

Get the Year of a date


Go to End


1251 Views

Avatar
Digitweaks

Community Member, 11 Posts

11 July 2017 at 3:36am

Hi everyone, i have dates defined in a dataobject like so

private static $db = array(
'DateStart'=>'Date',
'DateEnd'=>'Date',
);

when i try to get the Year by
$DateStart->Year() or $DateStart->Format('YYYY') or any kind of function, it's always either blank or i get an error.
I tried everything i could since hours, i still get no results.

So, what is the function i'm meant to use to get the Year, month and day of "Date" Object in the php file ?

Any help is welcome, thanks