Skip to content

Setting the Time Zone Dynamically #230

@adeeb1

Description

@adeeb1

I ran into the "Cannot determine timezone from nil" error and wanted to post my solution. It involves setting the ENV['TZ'] variable, as you suggested, but I don't like to hardcode values like this, especially if your time zone changes from development to production environments. You can let Ruby get the time zone more explicitly.

ENV['TZ'] = Time.zone.name
scheduler = Rufus::Scheduler.new
scheduler.every '2s' do
  puts "#{Time.now} Hello #{ENV['TZ']}!"
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions