1234567891011121314151617181920212223242526272829 |
- <?php
- /*
- * This file is part of the Jiannei/lumen-api-starter.
- *
- * (c) Jiannei <longjian.huang@foxmail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- namespace App\Support\Traits;
- use Carbon\Carbon;
- use DateTimeInterface;
- trait SerializeDate
- {
- /**
- * 为数组 / JSON 序列化准备日期。(Laravel 7).
- *
- * @param \DateTimeInterface $date
- * @return string
- */
- protected function serializeDate(DateTimeInterface $date)
- {
- return $date->format($this->dateFormat ?: Carbon::DEFAULT_TO_STRING_FORMAT);
- }
- }
|