Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Gotime Laravel Package

dcarbone/gotime

Go-inspired time utilities for PHP 8.1+: a Duration type (parse/format like 5s, JSON as nanoseconds) plus helpers to generate DateInterval specs for DateTime add/sub. Includes a Time wrapper around DateTime aiming for Go time.Time-style APIs.

View on GitHub
Deep Wiki
Context7

Golang-like time class(es) for PHP 7.0+

Frequently asked questions about Gotime
How do I install and use dcarbone/gotime in a Laravel project?
Install via Composer with `composer require dcarbone/gotime`. Use the `Time` class for Go-like time operations (e.g., `Time::Now()`) and `Duration` for parsing/manipulating time spans (e.g., `Duration::Parse('5s')`). Requires PHP 8.1+ and no Laravel-specific setup.
Does this package support Laravel’s Carbon facade or Eloquent timestamps?
No, it doesn’t integrate with Carbon or Eloquent. For Eloquent models, manually cast time fields using accessors/mutators. For Carbon compatibility, consider hybrid usage (e.g., use `gotime` for calculations, Carbon for I/O).
What Laravel versions does dcarbone/gotime support?
The package targets PHP 8.1+, which aligns with Laravel 9+ and 10. It’s framework-agnostic but works seamlessly with modern Laravel stacks. No Laravel-specific dependencies or version locks exist.
How accurate is the nanosecond precision in production?
Nanosecond precision is stored internally as integers (e.g., `5s` = `5e9`), but PHP’s `DateTime` and `DateInterval` may introduce edge cases (e.g., floating-point math). Test thoroughly for critical paths like scheduling or rate limiting.
Can I use gotime for timezone-aware operations like Carbon?
No, `gotime` treats durations as timezone-agnostic. For timezone handling, fall back to Carbon or PHP’s native `DateTime` methods. Use `gotime` for internal calculations where timezone context isn’t needed.
Are there breaking changes in v1.0.1, and how do I migrate?
The changelog lacks specifics, but v1.0.1 likely includes bug fixes without breaking changes. If upgrading from beta, review the `Time` class docs (still marked beta) for deprecated methods or API shifts.
How does gotime compare to Carbon for Laravel APIs?
Use `gotime` for internal time math (e.g., parsing `'1h30m'` or scheduling) and Carbon for user-facing dates/API responses. `gotime`’s fluent methods reduce boilerplate, but Carbon’s UX (e.g., `now()`, `parse()`) is superior for external interactions.
What alternatives exist for Go-like time handling in Laravel?
For simpler cases, consider `spatie/calendar` or custom `DateInterval` logic. For UUID-time hybrids, pair `ramsey/uuid` with Carbon. If nanosecond precision is critical, benchmark `gotime` against Carbon’s `createFromTimestamp()` for edge cases.
How do I serialize gotime objects to JSON or APIs?
Use `json_encode()` on `Duration` objects to output nanoseconds as integers (e.g., `5000000000` for `5s`). For `Time` objects, cast to a `DateTime` or format manually (e.g., `$time->format('Y-m-d')`). Avoid direct serialization of `Time` objects.
Is dcarbone/gotime actively maintained, and who supports it?
The package is v1.0 stable with low GitHub activity (2 stars, no dependents). Maintenance appears active (bug fixes in v1.0.1), but long-term support depends on the author. Monitor the repo for updates or consider forking if critical.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor