Reputation: 316
Im trying to update the updated_at
in laravel "2019-01-07 20:29:13"
to "2019-15-18 20:29:13"
, but the problem is the time keeps updating also to "2019-15-18 00:00:00"
. How to update updated_at
without touching the time ?
Upvotes: 1
Views: 1177
Reputation: 26258
Instead of updating updated_at
column you can add another column for this purpose and take it as date
type only (recommended). But if you are not allowed to do this then you can try:
Get the existing date
and hold it in a variable and break it to get date and time separately or you can extract the time only.
Combine your date
with this time
and make it datetime 'y-m-d H:i:s'
using date()
and strtotime()
functions.
Update the updated_at
column with this new datetime value.
Upvotes: 3