forked from mirror/gorm
Merge pull request #112 from siesta/timenowset
set updated_at and created_at with the same timestamp
This commit is contained in:
commit
2f8b1842d8
|
@ -13,8 +13,9 @@ func BeforeCreate(scope *Scope) {
|
|||
|
||||
func UpdateTimeStampWhenCreate(scope *Scope) {
|
||||
if !scope.HasError() {
|
||||
scope.SetColumn("CreatedAt", time.Now())
|
||||
scope.SetColumn("UpdatedAt", time.Now())
|
||||
now := time.Now()
|
||||
scope.SetColumn("CreatedAt", now)
|
||||
scope.SetColumn("UpdatedAt", now)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue