0

I'm trying to show timestamp on .rhtml page, but it returns something like this:

Mon Dec 09 21:03:22 +0400 2013

How it should be:

2013.12.09 21:03:22

What's wrong? This is how I do:

<%= message.time %>

1 Answers1

1

Use strftime

message.time.strftime("%Y.%m.%d %H:%M:%S")
Dan Grahn
  • 9,044
  • 4
  • 37
  • 74
  • `<%= message.time.strftime("%Y.%m.%d %H:%M:%s")%>` not working – user3083781 Dec 09 '13 at 17:22
  • What do you mean not working? It would help if you post what you see . Try with `S` instead of `s` for second `<%= message.time.strftime("%Y.%m.%d %H:%M:%S")%>` – usha Dec 09 '13 at 17:33
  • @Vimsha `%S - Second of the minute (00..60)` and `%s - Number of seconds since 1970-01-01 00:00:00 UTC.` – Roman Kiselenko Dec 09 '13 at 18:05
  • @Monk_Code: I know that. But for what user3083781 wants, it should be %S. Thank you for the explanation. – usha Dec 09 '13 at 18:11