$timestamp = 1609459200; // January 1, 2021 $carbon = \Carbon\Carbon::createFromTimestamp($timestamp); echo $carbon->toDateTimeString(); // Output: 2021-01-01 00:00:00
$timestamp = 1609462800; // January 1, 2021 01:00:00 UTC $timezone = 'America/New_York'; // Eastern Time (UTC-5) $carbon = \Carbon\Carbon::createFromTimestamp($timestamp, $timezone); echo $carbon->toDateTimeString(); // Output: 2020-12-31 20:00:00In the example above, we again use the `createFromTimestamp` method to create a Carbon object from a Unix timestamp representing January 1, 2021, but this time we also pass a timezone parameter. This creates a Carbon object with the correct timezone offset applied, which can be useful when working with datetime values across different timezones. Package Library: Carbon by nesbot\Carbon.