Date conversion

how to convert a “%d/%m/%Y” date to a “%Y/%m/%d” date?

if it’s a string then use the the split function. split it up by
the /. It should return 3 values after being split… the day, the
month, and the year. Then rearrange them.

Ben L. wrote:

if it’s a string then use the the split function. split it up by
the /. It should return 3 values after being split… the day, the
month, and the year. Then rearrange them.

or you can just use date_object.strftime("%Y/%m/%d")
and that should do the trick.

cheers,

s

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs