dateTimeFormat static method

Cast dateTimeFormat(
  1. String format
)

Laravel's datetime:FORMAT and date:FORMAT casts: the attribute reads as a DateTime and Model.toJson writes it with the PHP date() format ('Y-m-d H:i:s', 'd/m/Y', ...), in UTC, as Laravel 8 to 13 write a formatted timestamp (HasAttributes::addDateAttributesToArray serializes it to UTC before addCastAttributesToArray formats it). The value is stored as Y-m-d H:i:s, like dateTime.

Implementation

static Cast dateTimeFormat(String format) => DateTimeFormatCast(format);