Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
Polraudio

Check current date?

Question

Is there a way i can check the current date the computer has and do something if the date is a certian date?

 

EX: I want an event to appear on Holidays depending what holiday it is. Im also going to have quests that happen on certian days.

 

I only need it to check Day, Month, and Time(time is optional).

 

Thanks in advance :)

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Yupperz :D

 

Ruby comes with a `Time` class -

 

current_time = Time.now # Get current time/date
current_time.month # Get month as a number
current_time.day # Get the day number
current_time.hour # Get the current hour
current_time.min # Get the current minute
current_time.sec # Get the second
current_time.yday # Get the day of the year
current_time.wday # Get the day of the week

 

If you want more info about the time class and it's methods:

http://ruby-doc.org/core-1.9.3/Time.html

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...