From 4c0227e105a0f3f2ffcca40548ad4fb49ee3595e Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Mon, 12 Jan 2009 02:02:45 +0000 Subject: [PATCH] #3340 - Add extra date functions git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@69974 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/fieldtypes/Date.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/core/model/fieldtypes/Date.php b/core/model/fieldtypes/Date.php index a81d643f2..14bb04a43 100644 --- a/core/model/fieldtypes/Date.php +++ b/core/model/fieldtypes/Date.php @@ -197,8 +197,28 @@ class Date extends DBField { DB::requireField($this->tableName, $this->name, $values); } + /** + * Returns true if date is in the past. + * @return boolean + */ function InPast() { - return strtotime( $this->value ) < time(); + return strtotime($this->value) < time(); + } + + /** + * Returns true if date is in the future. + * @return boolean + */ + function InFuture() { + return strtotime($this->value) > time(); + } + + /** + * Returns true if date is today. + * @return boolean + */ + function IsToday() { + return (date('Y-m-d', strtotime($this->value)) == date('Y-m-d', time())); } /**