How do I get a Unix timestamp from Carbon?
Use Carbon::now('UTC')->timestamp for epoch seconds. This returns a 10-digit Unix integer that works for most APIs and databases.
If you searched for carbon to unix timestamp, you likely need a dependable epoch value for a Laravel API, queue worker, or scheduled command. In 2026, the safest workflow is to generate timestamps in UTC, store the raw integer, and format dates only when rendering UI or logs.
Carbon gives you both units: timestamp for seconds and valueOf() for milliseconds. Most backend contracts use seconds, while front-end analytics pipelines often expect milliseconds. Keeping the unit explicit prevents off-by-1000 bugs across PHP and JavaScript services.
Current Unix seconds
use Carbon\Carbon;
$epochSeconds = Carbon::now('UTC')->timestamp;Current Unix milliseconds
use Carbon\Carbon;
$epochMilliseconds = Carbon::now('UTC')->valueOf();Epoch to Carbon date
use Carbon\Carbon; $readableUtc = Carbon::createFromTimestamp(1700000000, 'UTC')->toIso8601String();
For more PHP examples, open Unix timestamp in PHP. To validate that your generated value is live, use current timestamp now. To decode historic log values, use Unix timestamp to date.
Need a full conversion flow with live UI? Open the main epoch converter tool.
If your Laravel job runs on a cron schedule, validate expressions with Cron Expression Builder before deployment.
Use Carbon::now('UTC')->timestamp for epoch seconds. This returns a 10-digit Unix integer that works for most APIs and databases.
Use Carbon::now('UTC')->valueOf() to get a 13-digit Unix timestamp in milliseconds. This is useful for JavaScript clients and event tracking.
No. Store Unix timestamps in UTC and convert to local time only in the view layer. This prevents timezone and daylight-saving inconsistencies.
Use Carbon::createFromTimestamp($seconds, 'UTC') for 10-digit values or createFromTimestampMs for 13-digit values, then format as needed.