Skip to main content

Mappers

DateTimeMapper

Expects as sql date time string or null as input and tries to convert the value to a DateTime object.

Validation possibilities

ValidationSavings
$mandatorybool
$minDateTimeInterface
$maxDateTimeInterface

Example

$result = Bind::values('2023-12-13 12:04:12')->map(Mappers::dateTime())->exec();
var_dump($result->get());

Output:

object(DateTime)#1 (3) {
["date"]=>
string(26) "2023-12-13 12:04:12.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}

DateTimeSqlMapper