Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created June 3, 2026 22:27
Show Gist options
  • Select an option

  • Save rust-play/4c7aa05327e5e2937079a4a82daa4009 to your computer and use it in GitHub Desktop.

Select an option

Save rust-play/4c7aa05327e5e2937079a4a82daa4009 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
// Required dependencies in Cargo.toml:
// [dependencies]
// chrono = "0.4"
use chrono::{TimeZone, Utc};
fn main() {
// Jupiter Opposition 2011-10-29 01:34:00 UTC
let datetime = Utc.with_ymd_and_hms(2011, 10, 29, 1, 34, 0).unwrap();
let unix_timestamp = datetime.timestamp();
println!("Event: Jupiter Opposition (2011)");
println!("UTC Date/Time: {}", datetime.to_rfc3339());
println!("Unix Epoch Timestamp: {}", unix_timestamp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment