Ruby Time Class


The Time class in Ruby has a powerful formatting function which can help you represent the time in a variety of ways. The Time class contains Ruby's interface to the set of time libraries written in C. Time zero for Ruby is the first second GMT of January 1, 1970. Ruby's DateTime class is superior to Time for astronomical and historical applications, but you can use Time for most everyday programs.

The strftime function is modelled after C's printf. The p042time.rb program shows some of these functions.

The output is:

Summary

I have listed down all the important points you need to remember after you have completed the following topics: Ruby Symbols, Access Control, Hashes, Ruby Time class.