Format a timestamp for display. Converts a UTC timestamp to local time and formats it in a human-readable format. # Arguments `timestamp` - The UTC timestamp to format # Returns A human-readable string representation of the timestamp. # Example ```rust,ignore let ts = Utc::now(); println!("Created: {}", format_timestamp(&ts)); // Output: "Created: 2024-01-15 10:30:45" ```
(timestamp: &DateTime<Utc>)
| 443 | /// // Output: "Created: 2024-01-15 10:30:45" |
| 444 | /// ``` |
| 445 | pub fn format_timestamp(timestamp: &DateTime<Utc>) -> String { |
| 446 | let local: DateTime<Local> = timestamp.with_timezone(&Local); |
| 447 | local.format("%Y-%m-%d %H:%M:%S").to_string() |
| 448 | } |
| 449 | |
| 450 | /// Format a timestamp in a relative format (e.g., "2 hours ago"). |
| 451 | /// |