Leave a comment

Dealing with Ruby time


I saw this code the other day:

– tempDate = “#{my_object_date.to_date}”
– displayDate = tempDate[5,2]
– displayDate += “/”
– displayDate += tempDate[8,2]
– displayDate += “/”
– displayDate += tempDate[0,4]
= displayDate

The result of this code is MM/DD/YY.

What the hell?  I am pretty sure that just about every computer language out there has ways to deal with dates.  For Ruby it is strftime.

Check out this awesome tool for dealing with dates and time in Ruby: http://www.foragoodstrftime.com/

And when in doubt, google it!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: