class DateTime extends Date

Class that represents an RDF Literal of datatype xsd:dateTime

Properties

protected $value from Literal
protected $lang from Literal
protected $datatype from Literal

Methods

static Literal
create(mixed $value, string $lang = null, string $datatype = null)

Create a new literal object

from Literal
static 
setDatatypeMapping(string $datatype, string $class)

Register an RDF datatype with a PHP class name

from Literal
static 
deleteDatatypeMapping(string $datatype)

Remove the mapping between an RDF datatype and a PHP class name

from Literal
static string
getDatatypeForValue(mixed $value)

Get datatype URI for a PHP value.

from Literal
__construct(string $value = null, string $lang = null, string $datatype = null)

Constructor for creating a new date and time literal

string
getValue()

Returns the date as a PHP DateTime object

from Date
string
getDatatypeUri()

Returns the full datatype URI of the literal.

from Literal
string
getDatatype()

Returns the shortened datatype URI of the literal.

from Literal
string
getLang()

Returns the language of the literal.

from Literal
array
toRdfPhp()

Returns the properties of the literal as an associative array

from Literal
string
__toString()

Magic method to return the value of a literal as a string

from Literal
string
dumpValue(string $format = 'html', string $color = 'black')

Return pretty-print view of the literal

from Literal
static Date
parse(string $value)

Parses a string using DateTime and creates a new literal

string
format(string $format)

Returns date formatted according to given format

from Date
integer
year()

A full integer representation of the year, 4 digits

from Date
integer
month()

Integer representation of the month

from Date
integer
day()

Integer representation of the day of the month

from Date
integer
hour()

24-hour format of the hour as an integer

integer
min()

The minutes pasts the hour as an integer

integer
sec()

The seconds pasts the minute as an integer

Details

in Literal at line 81
static Literal create(mixed $value, string $lang = null, string $datatype = null)

Create a new literal object

PHP values of type bool, int or float, will automatically be converted to the corresponding datatype and PHP sub-class.

If a registered datatype is given, then the registered subclass of EasyRdf\Literal will instantiated.

Note that literals are not required to have a language or datatype. Literals cannot have both a language and a datatype.

Parameters

mixed $value The value of the literal or an associative array
string $lang The natural language of the literal or null (e.g. 'en')
string $datatype The datatype of the literal or null (e.g. 'xsd:integer')

Return Value

Literal (or subclass of EasyRdf\Literal)

in Literal at line 132
static setDatatypeMapping(string $datatype, string $class)

Register an RDF datatype with a PHP class name

When parsing registered class will be used whenever the datatype is seen.

When serialising a registered class, the mapping will be used to set the datatype in the RDF.

Example: EasyRdf\Literal::registerDatatype('xsd:dateTime', 'My_DateTime_Class');

Parameters

string $datatype The RDF datatype (e.g. xsd:dateTime)
string $class The PHP class name (e.g. My_DateTime_Class)

Exceptions

InvalidArgumentException

in Literal at line 157
static deleteDatatypeMapping(string $datatype)

Remove the mapping between an RDF datatype and a PHP class name

Parameters

string $datatype The RDF datatype (e.g. xsd:dateTime)

Exceptions

InvalidArgumentException

in Literal at line 184
static string getDatatypeForValue(mixed $value)

Get datatype URI for a PHP value.

This static function is intended for internal use. Given a PHP value, it will return an XSD datatype URI for that value, for example: http://www.w3.org/2001/XMLSchema#integer

Parameters

mixed $value

Return Value

string A URI for the datatype of $value.

at line 61
Literal __construct(string $value = null, string $lang = null, string $datatype = null)

Constructor for creating a new date and time literal

If the value is a DateTime object, then it will be converted to the xsd:dateTime format. If no value is given or is is null, then the current time is used.

Parameters

string $value The value of the literal
string $lang The natural language of the literal or null (e.g. 'en')
string $datatype The datatype of the literal or null (e.g. 'xsd:string')

Return Value

Literal

See also

DateTime

in Date at line 97
string getValue()

Returns the date as a PHP DateTime object

Return Value

string Value of this literal.

See also

DateTime::format

in Literal at line 257
string getDatatypeUri()

Returns the full datatype URI of the literal.

Return Value

string Datatype URI of this literal.

in Literal at line 266
string getDatatype()

Returns the shortened datatype URI of the literal.

Return Value

string Datatype of this literal (e.g. xsd:integer).

in Literal at line 279
string getLang()

Returns the language of the literal.

Return Value

string Language of this literal.

in Literal at line 291
array toRdfPhp()

Returns the properties of the literal as an associative array

For example: array('type' => 'literal', 'value' => 'string value')

Return Value

array The properties of the literal

in Literal at line 313
string __toString()

Magic method to return the value of a literal as a string

Return Value

string The value of the literal

in Literal at line 325
string dumpValue(string $format = 'html', string $color = 'black')

Return pretty-print view of the literal

Parameters

string $format Either 'html' or 'text'
string $color The colour of the text

Return Value

string

at line 87
static Date parse(string $value)

Parses a string using DateTime and creates a new literal

Example: $dt = EasyRdf\Literal\DateTime::parse('Mon 18 Jul 2011 18:45:43 BST');

Parameters

string $value The date to parse

Return Value

Date

See also

DateTime

in Date at line 109
string format(string $format)

Returns date formatted according to given format

Parameters

string $format

Return Value

string

See also

DateTime::format

in Date at line 118
integer year()

A full integer representation of the year, 4 digits

Return Value

integer

in Date at line 127
integer month()

Integer representation of the month

Return Value

integer

in Date at line 136
integer day()

Integer representation of the day of the month

Return Value

integer

at line 97
integer hour()

24-hour format of the hour as an integer

Return Value

integer

at line 106
integer min()

The minutes pasts the hour as an integer

Return Value

integer

at line 115
integer sec()

The seconds pasts the minute as an integer

Return Value

integer