Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change time format in rails 3.0.1

anyone can help me with this?

In my view I have: <%= post.time %>

It displays on the screen for the row: Sat Jan 01 17:18:00 UTC 2000

In every row it says "Sat Jan 01" + "UTC 2000"

How can I get rid of it and display only the time?

Many thanks

like image 921
daniel Avatar asked Dec 17 '22 18:12

daniel


1 Answers

<%= post.date.strftime('%H:%M:%S') %>

You can read the reference for the full formatting syntax here. For example:

%S - Second of the minute (00..60)

%H - Hour of the day, 24-hour clock (00..23)

. . . and so on.

like image 92
Scott Avatar answered Dec 22 '22 00:12

Scott