'Laravel v9.x incorrect created_at time
I'm using $table->timestamps() for my tables.
The problem is when I create a new record, the created_at column datetime is different from column updated_at and also it's set to 2 days in the past.
created_at -> 2022-05-05 15:47:43
updated_at -> 2022-05-07 10:42:44
The updated_at is correct. I also overridden freshTimestamp method in the model.
public function freshTimestamp() {
return Carbon::now()->timestamp;
}
Update : Added order migration up method.
public function up() {
Schema::create('orders', function(Blueprint $table) {
$table->id();
$table->integer('amount');
$table->timestamp('expires_at');
$table->timestamps();
});
}
Solution 1:[1]
The problem could be on your column timestamp (for example sql server could have different time than web server) so please show the sql or migration code.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Durimi |
