Mappers
DateTimeMapper
Expects as sql date time string or null as input and tries to convert the value to a DateTime object.
Validation possibilities
| Validation | Savings |
|---|---|
| $mandatory | bool |
| $min | DateTimeInterface |
| $max | DateTimeInterface |
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"
}