So having trouble figuring this one out mainly because I don’t know the correct terminology. I want to print certain characters out of a string based on their place in the string.
Example. Let’s say I have a string 2012-08-18 being printed from RoR. Now, what I want to do is actually just print out the last two characters, in this case, 18. I always want to print the last two characters, as they will always be the day.
Thoughts?
Here’s my current code where I need to add this:
<%= event.start_date %>
which prints out
2012-08-18
Thanks.
If you only want the day numbers, you should use the method “strftime”
See here the documentation here on Rubyonrails.org
In your case, you can use this :
Hope this helps!