Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display the current date in "mm/dd/yyyy" format in Rails

In my view I want to display the current date in "mm/dd/yyyy" format.

like image 483
akshay1188 Avatar asked Sep 09 '10 14:09

akshay1188


People also ask

How do I change the date format in Ruby on Rails?

You need to convert your string into Date object. For that, use Date#strptime . You can use Date#strftime to convert the Date object into preferred format.

How do you print mm/dd/yyyy in Python?

Use strftime() function of a datetime class For example, the %d-%m-%Y %H:%M:%S codes convert date to dd-mm-yyyy hh:mm:ss format.


Video Answer


1 Answers

<%= Time.now.strftime("%m/%d/%Y") %> 
like image 88
Jeff Avatar answered Oct 19 '22 07:10

Jeff