Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Benko's avatar
Level 6

How to access date in a Carbon instance?

Assuming we have a Carbon instance of the date like so:

"created_at": {
"date": "2018-11-05 18:23:54.000000",
"timezone_type": 3,
"timezone": "UTC"
}

How do I access the mere date? I've tried ->date and ->getDate(), but to no avail.

0 likes
4 replies
Benko's avatar
Level 6

I will just add that ->toDateString() returns only date, but I should've said that I wanted date AND time. Either way, this solves the problem: ->toDateTimeString()

1 like

Please or to participate in this conversation.