ruby - Undefined method `strftime' for nil:NilClass -
i have variable: @delivery_time
.
when this
o.delivery_time.strftime("%h:%m:%s")
it gives
undefined method `strftime' nil:nilclass
and when this:
debug o.delivery_time
it gives:
--- 2000-01-01 11:00:00.000000000 z ...
also, output for:
o.delivery_time
is
2000-01-01 11:00:00 utc
here want value of time i.e. 11:00. tried srtftime not working.
can in this?
i have same kind of issue , following code helps me display hour , minutes field "time".
o.try(:delivery_time).try(:strftime, ("%h:%m"))
Comments
Post a Comment