开发者

Time display format problem

开发者 https://www.devze.com 2023-02-06 00:59 出处:网络
My object model has a attribute named \"start_at\" which is sotred in PostgreSQL database. Inside the database table, the type of \"start_at\" is \"time without time zone\" and one object start_at va

My object model has a attribute named "start_at" which is sotred in PostgreSQL database.

Inside the database table, the type of "start_at" is "time without time zone" and one object start_at value is e.g. 10:20:00.

However, when I render this time value to my index.html.haml view by using %td =myobj.start_at, the view page always show "Sat Jan 01 10:20:00 UTC 2000" ins开发者_如何学编程tead of 10:20:00.

How to get rid of it to show only 10:20:00 instead of the long string?


What about:

myobj.start_at.strftime('%H:%M:%S')

Check resource here: http://www.ruby-doc.org/core/classes/Time.html#M000392


use timeobj.strftime("%H:%M:%S")

you can view all the options for strftime here

0

精彩评论

暂无评论...
验证码 换一张
取 消