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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

time function


Go to End


899 Views

Avatar
Arbee

Community Member, 31 Posts

27 May 2010 at 10:34pm

Hi,

Can someone please help me with a time issue? I have dates in the database and want to determine if the current date is in between them. I have written a function using strtotime() which I thought was working but doesn't appear to be now. My two date fields look like this: 'RegStart' => 'Date', 'RegStop' => 'Date',

I wrote a function like this:
function openForReg() {
$regClass = DataObject::get('Product', "`Location` = 'AOQ'", "rand()", "", "1");
if (strtotime($this->RegStart) < time() AND strtotime($this->RegStop) > time()) return $regClass;
}

Where am I going wrong?
Thanks for any help.