我正在使用Laravel 4应用程序,并希望保存created_at和updated_at字段的unix时间戳,而不是默认的时间戳值.
有关如何实现这一目标的任何建议?
问候,
您可以获取时间戳属性,如下所示:
$timestamp = $model->created_at->timestamp;
Run Code Online (Sandbox Code Playgroud)
或者,您可以覆盖getDateFormat(),并创建必填字段的迁移,如下所示:
$table->integer('created_at');
$table->integer('updated_at');
Run Code Online (Sandbox Code Playgroud)