Return to Snippet

Revision: 80602
at March 21, 2020 23:33 by chrisaiv


Updated URL
https://www.chrisjmendez.com/2007/10/21/101-to-using-time-in-ruby/

Updated Code
https://www.chrisjmendez.com/2007/10/21/101-to-using-time-in-ruby/

Revision: 4075
at October 21, 2007 18:46 by chrisaiv


Initial Code
#Find out the Current Time
t = Time.now

#Find out the Month, Day, or Year individually
puts t.mon.to_s + "/" + t.day.to_s + "/" + t.year.to_s

#Find out the UTC
puts t.utc

###########################
#User Formatted Characters
###########################
#the String For Time function allows you to mix text with data
puts t.strftime("The Document print data is %m/%d/%Y")

#Another way to Display the Month Day, Year
puts t.strftime("%b %d, %Y")

Initial URL

                                

Initial Description
There are many functions available for Time, Month, Day, and Year. Below are a few examples I use frequently

Initial Title
101 to using Time in Ruby

Initial Tags
ruby

Initial Language
Ruby