How can I set timezone in simple form datetime field?

letz

I have a model with a datetime field, and is stored in UTC, how can I display that date in simple form gem in a specific timezone?

Already tried with the option input_html: {value: @model.date.in_time_zone('Eastern Time (US & Canada)')}

Note: I can't change the timezone of rails app

letz

It will work if you set the timezone in the controller:

Example:

around_action :set_time_zone, if: :current_user

private

def set_time_zone(&block)
   Time.use_zone(current_user.time_zone, &block)
end

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to set only hour in datetime field using simple_form?

From Dev

How to set only hour in datetime field using simple_form?

From Dev

How to set DateTime Field Value without TimeZone in XPages ServerSide JS

From Java

How can I manually set an Angular form field as invalid?

From Dev

How can i set another form field based on a checkbox?

From Dev

How can I set Timezone in lumen 5.2?

From Dev

Given an unzoned DateTime and a timezone, how can I construct an instant in NodaTime?

From Dev

How can I convert a JSON date with timezone to a SQL Server datetime?

From Dev

How can I batch convert timezone of DATETIME entries?

From Dev

Given an unzoned DateTime and a timezone, how can I construct an instant in NodaTime?

From Dev

How can I do to map "timestamp with timezone" to datetime

From Dev

Simple_form (rails) - How can I set default selected option if I have params[:id]

From Dev

Zope.Schema/Plone - How can I set the value of a Datetime field in an updateWidget function?

From Dev

How to set a default DateTime in field when new form is created?

From Dev

How to update a datetime field with timezone in postgresql

From Dev

How can I convert a string into a DateTime for a specific timezone, preserving the date exactly is it comes for that timezone?

From Dev

How can I convert a string into a DateTime for a specific timezone, preserving the date exactly is it comes for that timezone?

From Dev

How can I set MySQL server timezone to UTC?

From Dev

How can I set timezone UTC+2?

From Dev

How can I set MySQL server timezone to UTC?

From Dev

How can I make a django datetime field dependent on another field?

From Dev

Ruby on Rails, simple_form - I want to set a hidden field of the simple_form from a html select_tag field

From Dev

how to set timezone to eastern for DateTime module in python?

From Dev

How can I "set" a field in a record in Frege?

From Dev

How to set DateTime field as not required?

From Dev

How to set DateTime field as not required?

From Dev

How can I update date of datetime field with mysql only?

From Dev

How can I use set methods to set data field?

From Dev

How can I create a DateTime object from a string that is already in a specific timezone?

Related Related

  1. 1

    How to set only hour in datetime field using simple_form?

  2. 2

    How to set only hour in datetime field using simple_form?

  3. 3

    How to set DateTime Field Value without TimeZone in XPages ServerSide JS

  4. 4

    How can I manually set an Angular form field as invalid?

  5. 5

    How can i set another form field based on a checkbox?

  6. 6

    How can I set Timezone in lumen 5.2?

  7. 7

    Given an unzoned DateTime and a timezone, how can I construct an instant in NodaTime?

  8. 8

    How can I convert a JSON date with timezone to a SQL Server datetime?

  9. 9

    How can I batch convert timezone of DATETIME entries?

  10. 10

    Given an unzoned DateTime and a timezone, how can I construct an instant in NodaTime?

  11. 11

    How can I do to map "timestamp with timezone" to datetime

  12. 12

    Simple_form (rails) - How can I set default selected option if I have params[:id]

  13. 13

    Zope.Schema/Plone - How can I set the value of a Datetime field in an updateWidget function?

  14. 14

    How to set a default DateTime in field when new form is created?

  15. 15

    How to update a datetime field with timezone in postgresql

  16. 16

    How can I convert a string into a DateTime for a specific timezone, preserving the date exactly is it comes for that timezone?

  17. 17

    How can I convert a string into a DateTime for a specific timezone, preserving the date exactly is it comes for that timezone?

  18. 18

    How can I set MySQL server timezone to UTC?

  19. 19

    How can I set timezone UTC+2?

  20. 20

    How can I set MySQL server timezone to UTC?

  21. 21

    How can I make a django datetime field dependent on another field?

  22. 22

    Ruby on Rails, simple_form - I want to set a hidden field of the simple_form from a html select_tag field

  23. 23

    how to set timezone to eastern for DateTime module in python?

  24. 24

    How can I "set" a field in a record in Frege?

  25. 25

    How to set DateTime field as not required?

  26. 26

    How to set DateTime field as not required?

  27. 27

    How can I update date of datetime field with mysql only?

  28. 28

    How can I use set methods to set data field?

  29. 29

    How can I create a DateTime object from a string that is already in a specific timezone?

HotTag

Archive