SilverStripe 2.4 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
Version: master
  • master
  • 3.1
  • 3.0
  • 2.4
  • tagfield

Packages

  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • publishers
    • reports
    • security
    • tasks
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • installer
  • None
  • PHP
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets

Classes

  • Boolean
  • ComponentSet
  • Currency
  • DatabaseAdmin
  • DataObject
  • DataObjectDecorator
  • DataObjectLog
  • DataObjectSet
  • DataObjectSet_Iterator
  • Date
  • DB
  • DBField
  • Decimal
  • Double
  • Enum
  • Float
  • ForeignKey
  • Hierarchy
  • HTMLText
  • HTMLVarchar
  • Int
  • Money
  • MultiEnum
  • MySQLDatabase
  • MySQLQuery
  • Percentage
  • PrimaryKey
  • SiteTreeDecorator
  • SQLMap
  • SQLMap_Iterator
  • SQLQuery
  • SS_Database
  • SS_Datetime
  • SS_Query
  • SS_Transliterator
  • StringField
  • Text
  • Time
  • Transliterator
  • Varchar
  • Versioned
  • Versioned_Version
  • Year

Interfaces

  • CompositeDBField
  • CurrentPageIdentifier
  • DataObjectInterface

Class Date

Represents a date field. The field currently supports New Zealand date format (DD/MM/YYYY), or an ISO 8601 formatted date (YYYY-MM-DD). Alternatively you can set a timestamp that is evaluated through PHP's built-in date() function according to your system locale.

Example definition via DataObject::$db:

static $db = array(
        "Expires" => "Date",
);
Object
Extended by ViewableData implements IteratorAggregate
Extended by DBField
Extended by Date

Direct known subclasses

SS_Datetime

Package: sapphire\model
Located at sapphire/core/model/fieldtypes/Date.php

Methods summary

public
# setValue( mixed $value )

Set the value on the field. Optionally takes the whole record as an argument, to pick other values.

Set the value on the field. Optionally takes the whole record as an argument, to pick other values.

Parameters

$value
mixed
$value

Overrides

DBField::setValue
public
# Nice( )

Returns the date in the format dd/mm/yy

Returns the date in the format dd/mm/yy

public
# NiceUS( )

Returns the date in US format: “01/18/2006”

Returns the date in US format: “01/18/2006”

public
# Year( )

Returns the year from the given date

Returns the year from the given date

public
# Day( )

Returns the Full day, of the given date.

Returns the Full day, of the given date.

public
# Month( )

Returns a full textual representation of a month, such as January.

Returns a full textual representation of a month, such as January.

public
# ShortMonth( )

Returns the short version of the month such as Jan

Returns the short version of the month such as Jan

public
# DayOfMonth( )

Returns the date of the month

Returns the date of the month

public
# Long( )

Returns the date in the format 24 December 2006

Returns the date in the format 24 December 2006

public
# Full( )

Returns the date in the format 24 Dec 2006

Returns the date in the format 24 Dec 2006

public string
# Format( string $format )

Return the date using a particular formatting string.

Return the date using a particular formatting string.

Parameters

$format
string
$format Format code string. e.g. "d M Y" (see http://php.net/date)

Returns

string
The date in the requested format
public
# FormatI18N( mixed $formattingString )

Return the date formatted using the given strftime formatting string.

Return the date formatted using the given strftime formatting string.

strftime obeys the current LC_TIME/LC_ALL when printing lexical values like day- and month-names

public
# RangeString( mixed $otherDateObj )
public
# Rfc822( )
public
# Rfc2822( )
public
# Rfc3339( )
public
# Ago( )

Returns the number of seconds/minutes/hours/days or months since the timestamp

Returns the number of seconds/minutes/hours/days or months since the timestamp

public
# TimeDiff( )
public string
# TimeDiffIn( string $format )

Gets the time difference, but always returns it in a certain format

Gets the time difference, but always returns it in a certain format

Parameters

$format
string
$format The format, could be one of these: 'seconds', 'minutes', 'hours', 'days', 'months', 'years'.

Returns

string
public
# requireField( )

Add the field to the underlying database.

Add the field to the underlying database.

public boolean
# InPast( )

Returns true if date is in the past.

Returns true if date is in the past.

Returns

boolean
public boolean
# InFuture( )

Returns true if date is in the future.

Returns true if date is in the future.

Returns

boolean
public boolean
# IsToday( )

Returns true if date is today.

Returns true if date is today.

Returns

boolean
public
# URLDate( )

Returns a date suitable for insertion into a URL and use by the system.

Returns a date suitable for insertion into a URL and use by the system.

public
# days_between( mixed $fyear, mixed $fmonth, mixed $fday, mixed $tyear, mixed $tmonth, mixed $tday )
public
# day_before( mixed $fyear, mixed $fmonth, mixed $fday )
public
# next_day( mixed $fyear, mixed $fmonth, mixed $fday )
public
# weekday( mixed $fyear, mixed $fmonth, mixed $fday )
public
# prior_monday( mixed $fyear, mixed $fmonth, mixed $fday )
public static string
# past_date( mixed $fmonth, mixed $fday = 1, mixed $fyear = null )

Return the nearest date in the past, based on day and month. Automatically attaches the correct year.

Return the nearest date in the past, based on day and month. Automatically attaches the correct year.

This is useful for determining a financial year start or end date.

Parameters

$fmonth
mixed
$fmonth int The number of the month (e.g. 3 is March, 4 is April)
$fday
mixed
$fday int The day of the month
$fyear
mixed
$fyear int Determine historical value

Returns

string
Date in YYYY-MM-DD format
public FormField
# scaffoldFormField( string $title = null, mixed $params = null )

Returns a FormField instance used as a default for form scaffolding.

Returns a FormField instance used as a default for form scaffolding.

Used by SearchContext, ModelAdmin, DataObject::scaffoldFormFields()

Parameters

$title
string
$title Optional. Localized title of the generated instance
$params

Returns

FormField

Overrides

DBField::scaffoldFormField

Methods inherited from DBField

ATT(), HTML(), HTMLATT(), JS(), LowerCase(), RAW(), RAWURLATT(), URLATT(), UpperCase(), XML(), __construct(), addToQuery(), create(), debug(), defaultSearchFilter(), exists(), forTemplate(), getName(), getValue(), hasValue(), nullValue(), prepValueForDB(), saveInto(), scaffoldSearchField(), setName(), setTable(), writeToManipulation()

Methods inherited from ViewableData

ATT_val(), BaseHref(), CSSClasses(), CurrentMember(), CurrentPage(), Debug(), Even(), EvenOdd(), First(), FirstLast(), HasPerm(), IsAjax(), JS_val(), Last(), Me(), Middle(), MiddleString(), Modulus(), MultipleOf(), Odd(), Pos(), RAW_val(), SQL_val(), ThemeDir(), Top(), TotalItems(), XML_val(), __get(), __isset(), __set(), buildCastingCache(), cachedCall(), castingClass(), castingHelper(), castingHelperPair(), castingObjectCreator(), castingObjectCreatorPair(), customise(), defineMethods(), escapeTypeForField(), getField(), getIterator(), getSecurityID(), getXMLValues(), hasField(), i18nLocale(), iteratorProperties(), obj(), renderWith(), setCustomisedObj(), setField()

Methods inherited from Object

__call(), __toString(), addMethodsFrom(), addStaticVars(), addWrapperMethod(), add_extension(), add_static_var(), allMethodNames(), cacheToFile(), cacheToFileWithArgs(), clearCache(), combined_static(), createMethod(), create_from_string(), extInstance(), extend(), getCustomClass(), getExtensionInstance(), getExtensionInstances(), get_extensions(), get_static(), hasExtension(), hasMethod(), has_extension(), invokeWithExtensions(), is_a(), loadCache(), parentClass(), parse_class_spec(), remove_extension(), sanitiseCachename(), saveCache(), set_stat(), set_static(), set_uninherited(), stat(), strong_create(), uninherited(), uninherited_static(), useCustomClass()

Magic methods summary

Properties summary

Properties inherited from DBField

$arrayValue, $defaultVal, $default_search_filter_class, $escape_type, $name, $tableName, $value

Properties inherited from ViewableData

$casting, $customisedObject, $default_cast, $failover, $iteratorPos, $iteratorTotalItems

Properties inherited from Object

$class, $extension_instances, $extensions

Comments

Comment policy: Please use comments for tips and corrections about the described functionality. Comments are moderated, we reserve the right to remove comments that are inappropriate or are no longer relevant.
Use the Silverstripe Forum to ask questions.
blog comments powered by Disqus
SilverStripe 2.4 API Docs API documentation generated by ApiGen 2.8.0