---
title: "brick/date-time: RFC 3339 compliant seconds in PHP | VulCode"
description: "A fix in brick/date-time, the PHP date library: Instant and ZonedDateTime now always print the seconds in toISOString and JSON, as RFC 3339 requires."
url: "https://vulcode.com/en/opensource/contributions/brick-date-time"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

brick/date-time

# brick/date-time

A PHP date and time library based on the java.time model, with separate types for an instant, a date, a time and a zoned date-time.

[See the repository](https://github.com/brick/date-time) [All contributions](https://vulcode.com/en/opensource/contributions)

- **Language**: PHP
- **GitHub stars**: 361
- **Merged changes**: 1

## What we changed

Instant and ZonedDateTime always print the seconds in toISOString(), and so also in JSON and string casts, even when they are zero, as RFC 3339 requires.

### What this work shows

- RFC 3339 and ISO 8601 date formats

- Serialising dates to JSON in PHP

- PHPUnit data provider tests

What was broken

### Whole minutes printed without seconds

Instant::toISOString() and ZonedDateTime::toISOString() used LocalTime's compact form, which drops zero seconds, so a whole minute came out as 2023-11-14T22:14Z. That is a valid ISO 8601 time but not RFC 3339, which requires seconds, and the same string went into JSON through jsonSerialize().

How we fixed it

### Always HH:MM:SS in the interchange types

ZonedDateTime::toISOString() now builds the time itself, with mandatory seconds and the existing fraction handling, and Instant inherits the fix. LocalTime deliberately keeps its compact form, the parser still accepts the short input, and we updated the tests that pinned the old output and added whole-minute and whole-hour cases.

[#131](https://github.com/brick/date-time/pull/131)

## Merged change 1

- [#131 fix: emit full seconds in Instant and ZonedDateTime toISOString (RFC 3339) Merged 30 September 2026](https://github.com/brick/date-time/pull/131)

## What it taught us

An almost ISO 8601 format passes one parser and fails a strict RFC 3339 one. We can change the output format only in the types meant for data exchange, keep the compact form where it is intended, and fix the tests that pinned the bug.

[More about this technology: PHP](https://vulcode.com/en/technologies/php)

## Other projects we write code for

- [**Composer** PHP · 29,590 stars The dependency manager for PHP: it installs and updates a project's libraries from its composer.json.](https://vulcode.com/en/opensource/contributions/composer)

- [**PHPMailer** PHP · 22,347 stars The classic PHP library for sending email, used by WordPress and many other systems.](https://vulcode.com/en/opensource/contributions/phpmailer)

- [**Monolog** PHP · 21,407 stars A PHP logging library that sends records to files, sockets, inboxes, databases and web services. Symfony and Laravel use it, among others.](https://vulcode.com/en/opensource/contributions/monolog)

- [**Carbon** PHP · 16,583 stars A PHP DateTime extension for working with dates, standard in the Laravel ecosystem.](https://vulcode.com/en/opensource/contributions/carbon)

- [**Whoops** PHP · 13,231 stars A PHP library that turns uncaught exceptions into a readable error page with the stack trace, known from Laravel.](https://vulcode.com/en/opensource/contributions/whoops)

- [**ramsey/uuid** PHP · 12,642 stars A PHP library for generating universally unique identifiers (UUIDs).](https://vulcode.com/en/opensource/contributions/ramsey-uuid)

## Describe your project.

A free quote comes back within an hour during working hours.

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
