Q:
Rust program to convert the timestamp into readable date time
belongs to collection: Rust Date and Time Programs
Rust Date and Time Programs
- Rust program to get the UTC current date and time
- Rust program to get the current date and time based on local time zone
- Rust program to get the current timestamp
- Rust program to convert the timestamp into readable date time
- Rust program to print date-time in a formatted manner using format() function
- Rust program to create a date object using ymd() function
- Rust program to create a date-time object using ymd() and and_hms() function
- Rust program to get the date of the specified day of the specified year
- Rust program to demonstrate the and_hms_milli(), and_hms_micro(), and and_hms_nano() functions
- Rust program to print the current year using year() method
- Rust program to print the current month using month() method
- Rust program to print the current day using day() method
- Rust program to print the current hour, minute, second individually
- Rust program to print today\'s weekday using the weekday () method
- Rust program to compare weekdays with a current weekday
- Rust program to get the current weekday number from Monday
- Rust program to print the day of the year
- Rust program to demonstrate the Utc::today() and Local::today() functions
- Rust program to demonstrate the Utc::now().date() and Utc::now().time() functions
- Rust program to convert local date-time in UTC date-time
- Rust program to print the current date-time according to CHINA time-zone
- Rust program to print the current date-time according to RIO (Brazil) time-zone
- Rust program to print the time in 12-hour format
- Rust program to demonstrate the num_days_from_ce() function
- Rust program to print the UTC date-time in RFC 2822
- Rust program to print the UTC date-time in RFC 3339
- Rust program to parse the date-time from RFC 2822 string
- Rust program to parse the date-time from RFC 3339 string
- Rust program to parse only time from a string
- Rust program to parse only date from a string
- Rust program to parse the date and time from a string
Program/Source Code:
The source code to convert the timestamp into readable date-time is given below. The given program is compiled and executed on UBUNTU 18.04 successfully.
Output:
Explanation:
In the above program, we imported the "Chrono" library to our project for performing date and time operations. We imported the Chrono library using the below line:
In the main() function, we got the current date and time using the Utc::now() method and converted the date-time into timestamp using the timestamp() method. After that, we converted the timestamp into readable date time format and printed the result.
need an explanation for this answer? contact us directly to get an explanation for this answer