Mateusz Urbański
Mateusz Urbański

Reputation: 7862

Rails Date.today to MMDD format

How can I transform Date.today object to return the date in format MMDD?
For instance, for today, this should be:

0304

Upvotes: 0

Views: 89

Answers (1)

Marek Lipka
Marek Lipka

Reputation: 51151

You should use strftime method:

Date.today.strftime('%d%m')
# => "0304"

Upvotes: 1

Related Questions