且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将碳日期转换为 mysql 时间戳.

更新时间:2023-02-03 15:06:06

你也可以在你的模型上设置 Mutator.

You can also set Mutator on your model.

public function setPublishedAt($value)
{
    $this->attributes['published_at'] = strtotime($value);
}

转换为时间戳

$model -> setPublishedAt('2015-08-26'); // 1440572400

或者您可以使用 strtotime

strtotime — 将任何英文文本日期时间描述解析为 Unix 时间戳

strtotime — Parse about any English textual datetime description into a Unix timestamp

希望对您有所帮助.