Carbon has a lot of pre-defined getters for formatting times, for example ->toString(), ->toDateString() and ->toIso8601String().
Most of them differ, so you may have wondered what their differences are – below is a list for you:
Method | Output |
---|---|
toAtomString() | 2024-01-01T00:00:00+00:00 |
toCookieString() | Monday, 01-Jan-2024 00:00:00 UTC |
toDateString() | 2024-01-01 |
toDateTimeLocalString() | 2024-01-01T00:00:00 |
toDateTimeString() | 2024-01-01 00:00:00 |
toDayDateTimeString() | Mon, Jan 1, 2024 12:00 AM |
toFormattedDateString() | Jan 1, 2024 |
toFormattedDayDateString() | Mon, Jan 1, 2024 |
toISOString() | 2024-01-01T00:00:00.000000Z |
toIso8601String() | 2024-01-01T00:00:00+00:00 |
toIso8601ZuluString() | 2024-01-01T00:00:00Z |
toNow() | 5 months from now |
toRfc1036String() | Mon, 01 Jan 24 00:00:00 +0000 |
toRfc1123String() | Mon, 01 Jan 2024 00:00:00 +0000 |
toRfc2822String() | Mon, 01 Jan 2024 00:00:00 +0000 |
toRfc3339String() | 2024-01-01T00:00:00+00:00 |
toRfc7231String() | Mon, 01 Jan 2024 00:00:00 GMT |
toRfc822String() | Mon, 01 Jan 24 00:00:00 +0000 |
toRfc850String() | Monday, 01-Jan-24 00:00:00 UTC |
toRssString() | Mon, 01 Jan 2024 00:00:00 +0000 |
toString() | Mon Jan 01 2024 00:00:00 GMT+0000 |
toTimeString() | 00:00:00 |
toW3cString() | 2024-01-01T00:00:00+00:00 |