Freeze time in PHP tests with Carbon setTestNow
Freeze Carbon::now() in PHP tests with setTestNow, reset it after each test, and avoid date leakage across your suite.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Freeze Carbon::now() in PHP tests with setTestNow, reset it after each test, and avoid date leakage across your suite.
Carbon’s Duration object lets you add, subtract, and compare complex periods in PHP with a single line. Learn how to use it, what pitfalls to watch for, and a practical example that saves you from manual timestamp math.
In a Declarative Pipeline, I need to display the build start time in a specific regional time zone (e.g., America/New_York) for a report generated later in the pipeline. The pipeline runs on agents with varying system time zones, and I want to avoid relying on the agent's local time; I prefer to use a pure Groovy solution within the pipeline script. I am uns
You need to persist event timestamps in UTC and later present them in a user‑specific regional time zone, accounting for daylight‑saving shifts. Using a DigitalOcean Managed PostgreSQL database, you store the values as timestamptz and plan to convert them with the AT TIME ZONE operator when querying. However, you are unsure how the operator treats the input
In a Fiber application, I need to parse incoming ISO‑8601 timestamps from JSON payloads, interpret them as UTC, then convert to a user‑specified regional time zone (e.g., America/New_York) for storage or display. The standard library time package offers conversion, but I am unsure how to handle ambiguous or non‑existent times during DST transitions safely wi
When working with dates in Godot 4.x, I receive a Unix timestamp (seconds since the epoch) and need to represent it as a local date/time for a specific IANA time zone, such as “Europe/Paris”. The engine provides OS.get_unix_time() and the Date class, but it is unclear whether these functions automatically apply the zone’s offset or if I must calculate it man
Goal: Determine whether Sequelize should automatically apply the instance‑level timezone to DATE values when the underlying dialect stores them in a timezone‑aware column type (e.g., PostgreSQL timestamptz) or leave the values unchanged, ensuring a predictable mapping between model definitions and database storage across MySQL, SQLite and PostgreSQL. Constra
The primary objective is to guarantee that date values stored in the database, cast by Lucid, and exposed through API responses all reflect the same regional time zone defined in the framework’s global configuration. AdonisJS v5 ships with Luxon integration, and the config/app.ts file exposes a 'timezone' key that influences date parsing and formatting. Howe
Goal: Convert a DateTime value whose Kind is Unspecified but which logically represents a specific time zone (e.g., Eastern Standard Time) to UTC while preserving the original zone’s identity for future conversions. Constraint: TimeZoneInfo.ConvertTime(DateTime, TimeZoneInfo) interprets Unspecified as the system local zone and provides no overload to supply