Ruby Basic Exercises: Display the current date and time
Write a Ruby program to display the current date and time.

Ruby Code:
require 'date'
current_time = DateTime.now
cdt = current_time.strftime "%d/%m/%Y %H:%M"
puts "Current Date and Time: "+cdt
Output:
Current Date and Time: 27/12/2017 10:30
Flowchart:

Ruby Code Editor:
Contribute your code and comments through Disqus.
Contribute your code and comments through Disqus.
Previous: Write Ruby program to get ruby version with patch number.
Next: Write a Ruby program to create a new string which is n copies of a given string where n is a non-negative integer.
What is the difficulty level of this exercise?
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics