## Apache Zeta Components Manual :: Docs For Class ezcPersistentPropertyDateTimeConverter

### PersistentObject::ezcPersistentPropertyDateTimeConverter

### Class ezcPersistentPropertyDateTimeConverter

Property converter class for date/time values.

An instance of this class can be used with ezcPersistentObjectProperty in a ezcPersistentObjectDefinition to indicate, that a database date/time value (represented by a unix timestamp integer value) should be converted to a PHP DateTime object.

Source for this file: /PersistentObject/src/object/property_converters/date.php

### Implements interfaces:

- ezcPersistentPropertyConverter

Version: | //autogen//

### Method Summary

public static ezcPersistentPropertyConverter | `__set_state( $state )` Method for de-serialization after var_export().
public DateTime|null | `fromDatabase( $databaseValue )` Converts unix timestamp to DateTime instance.
public int|null | `toDatabase( $propertyValue )` Converts a DateTime object into a unix timestamp.

### Methods

#### __set_state

static ezcPersistentPropertyConverter __set_state( $state )

Method for de-serialization after var_export().

This methid must be implemented to allow proper de-serialization of converter objects, when they are exported using http://www.php.net/var_export.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$state` | array |

##### Implementation of:

Method | Description
--- | ---
`ezcPersistentPropertyConverter::__set_state()` | Method for de-serialization after var_export().

#### fromDatabase

DateTime|null fromDatabase( int|null $databaseValue )

Converts unix timestamp to DateTime instance.

This method is called right after a column value has been read from the database, given the $databaseValue. The value returned by this method is then assigned to the persistent objects property.

The given integer value $databaseValue is handled as a date/time value in unix timestamp representation. A corresponding DateTime object is returned, representing the same date/time value.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$databaseValue` | int|null |

##### Exceptions:

Type | Description
--- | ---
`ezcBaseValueException` | if the given $databaseValue is not an integer.

##### Implementation of:

Method | Description
--- | ---
`ezcPersistentPropertyConverter::fromDatabase()` | Converts the database value given to the property value.

#### toDatabase

int|null toDatabase( DateTime|null $propertyValue )

Converts a DateTime object into a unix timestamp.

This method is called right before a property value is written to the database, given the $propertyValue. The value returned by this method is then written back to the database.

The method expects a DateTime object in $propertyValue and returns the date/time value represented by it as an integer value in unix timestamp format.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$propertyValue` | DateTime|null |

##### Exceptions:

Type | Description
--- | ---
`ezcBaseValueException` | if the given $propertyValue is not an instance of DateTime.

##### Implementation of:

Method | Description
--- | ---
`ezcPersistentPropertyConverter::toDatabase()` | Converts the object value given back to the database value.

Documentation generated by phpDocumentor 1.4.3