adam78
adam78

Reputation: 10078

Carbon::parse get just date

I have a date stored as follows:

$user->password_expiry_dt

Carbon @1573228178 {#647 ▼
    date: 2019-11-08 15:49:38.0 UTC (+00:00)
}

I want to check if its expired without using the timestamp so currently i'm doing this:

Carbon::parse($user->password_expiry_dt)->hour(0)->minute(0)->second(0) <= Carbon::today()

Is there an easier or more elegant way to get the date without the timestamp as follows without having to chain all these extra setters?

2019-11-08 00:00:00.0 

Upvotes: 0

Views: 204

Answers (1)

Pavel Lint
Pavel Lint

Reputation: 3537

I think Carbon::parse($user->password_expiry_dt)->startOfDay() will do it for you

Upvotes: 1

Related Questions