This is my date 20100816 and it integer date.
How to display it like 08/16/2010?
You can use the Date.strptime method to read a date in a given format and strftime to print it out in another format:
require 'date'
intdate = 20100816
Date.strptime(intdate.to_s, "%Y%m%d").strftime("%m/%d/%Y")
#=> "08/16/2010"
You can use the Date.parse method and strftime to format the date
Date.parse(20100816.to_s).strftime("%m/%d/%Y")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With