php - Rails get time in HH:MM AM/PM -


i have php code converting time hh:mm format

date("g:i a", strtotime('2000-01-01 07:00:00 utc')

i want convert same function in rails.

i tried datetime.parse('2000-01-01 07:00:00 utc').strftime("%i:%m %p")

which showing error : no implicit conversion of time string

i eproduced error :

datetime.parse(time.now).strftime("%i:%m %p") # typeerror: no implicit conversion of time string 

this because parse methods accept string objects, not other objects. time object in case. have :

datetime.parse(time_object.to_s).strftime("%i:%m %p") # or directly time_object.strftime("%i:%m %p") 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -