Expand description
PHP date patterns for Rust.
PhpDatePattern formats like DateTime::format() and parses like DateTime::createFromFormat(), in English,
with PhpDateTime and Zone for time zones. formats resolves which pattern applies from a
DateConfig and exports patterns to Day.js.
use php_dates::{PhpDatePattern, PhpDateTime, Zone};
let pattern = PhpDatePattern::compile("d/m/Y H:i T")?;
let madrid = Zone::parse("Europe/Madrid").ok_or("unknown zone")?;
let date = PhpDateTime::new(jiff::civil::date(2026, 7, 1).at(8, 30, 0, 0), madrid)?;
assert_eq!(pattern.format(&date), "01/07/2026 08:30 CEST");jiff is re-exported: its types are part of this crate’s API. The tzdb-bundle feature builds the time zone
database into the binary, for systems without one.
Re-exports§
Modules§
- formats
- The date format contract: PHP patterns on the server;
frontend_configexports the equivalent Day.js patterns.
Structs§
- Date
Config - Where the date patterns of an application are configured: one per kind, one per purpose, and two legacy settings used when nothing else is set.
- Date
Patterns - One pattern per kind.
- Parse
Error - Why a value did not match a pattern.
- PhpDate
Pattern - A compiled PHP date pattern.
- PhpDate
Time - A date and time with its time zone: what
DateTime::format()prints andcreateFromFormat()returns.
Enums§
- Error
- A date pattern that cannot be used.
- Zone
- A time zone, in the three forms PHP has: an identifier, an abbreviation and a fixed offset.
Type Aliases§
- Result
- A date pattern that failed validation.