Skip to content

Instantly share code, notes, and snippets.

@maecha
Last active March 29, 2018 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maecha/3a873617368e324171e7372be34d02c9 to your computer and use it in GitHub Desktop.
Save maecha/3a873617368e324171e7372be34d02c9 to your computer and use it in GitHub Desktop.
Get the datetime from time. / E.g. From request params
def get_datetime_converted_from_time
time = Time.zone.now
splited_time = params[:object][:time].split(':')
local_time = Time.local(
time.year,
time.month,
time.day,
splited_time.first.to_i,
splited_time.last.to_i,)
@datetime = {
'time' => local_time,}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment