expression
Chrono signed Unix timestamp
Use seconds and nanoseconds with explicit units. Negative seconds can represent pre-epoch times; a millisecond count must not be passed as seconds. This example uses external crates; see the staged Cargo manifest. Expected stdout (not executed): -1 -500 Common mistake: Assuming timestamp() truncates a negative fractional second toward zero.
Formal Syntax & Structure
rust syntaxrust
DateTime::from_timestamp(seconds, nanos) -> Option<DateTime<Utc>>Working Example
Example Snippetrust
fn main() { use chrono::DateTime; let t = DateTime::from_timestamp(-1, 500_000_000).unwrap(); println!("{} {}", t.timestamp(), t.timestamp_millis());}