we are following MVC pattern, which is best place for converting toUTC and toLocal in controller or in javascript? Also whether we need to save the date format in invariant culture to support globalization? (or) is there any standard thumb rule/best practice for globalizing date time formats in MVC?
Globalizing date & time format in MVC
763 Views Asked by racha At
1
There are 1 best solutions below
Related Questions in .NET
- Does compiler optimize operation on const variable and literal const number?
- What is the point of definnig Asp.net Intrinsic Objects In different places and what is the different betwen them?
- Deleting Orphans with Fluent NHibernate
- IOrderedEnumerable to vb.net IOrderedEnumerable Conversion
- What is this namespace ITypeOfObjectsBoundToListBox ? Couldn't find it
- .net rest service with JSON string and consumed with java client
- What is best way to check if any of the property of object is null or empty?
- Telerik's WPF RadColorPicker NoColorText property not working
- Possible consequences of duplicate ProgId for different classes
- How are multiple requests to Task.Run handled from a resource management standpoint?
- Optimizing C++ call from C#
- Make a per-web-application object available to Web API and SignalR controllers
- System.ComponentModel.DataAnnotations.Schema namespace conflict
- LINQ Except/Distinct based on few columns only, to not add duplicates
- Not displaying content by its URL string - absolute urls
Related Questions in ASP.NET-MVC
- Can MVC.NET prevent SQL-injection at razor or controller level?
- Getting and passing MVC Model data to AngularJS controller
- Access property of an object of type [Model] in JQuery
- Entity Framework Code First with Fluent API Concurrency `DbUpdateConcurrencyException` Not Raising
- Bundling and minification issue in MVC
- ASP-MVC Code-first migrations checkbox not active
- Why does Azure CloudConfigurationManager.GetSetting return null
- Dynamic roles list in CustomAuthorize ASP MVC
- Jquery: Change contents of <select> tag dynamically
- Why web API return 404 when deploy to IIS
- MVC route URL not containing parameter
- Invalidate user credentials when password changes
- MVC : Insert data to two tables
- MVC - Only allow users to edit their own data
- Submit Button on Razor View doesn't call Action Result - MVC
Related Questions in DATETIME
- Python datetime.now() with timezone
- Create a list of sequential monthly dates in PHP given initial date and quantity
- DataTable RowFilter on Time component of DateTime column
- Joda DateTime Json date format issue
- how to create folder and file with datetime in wpf application
- String concatenation with padded integers
- What is the correct DateTime format in WebSQL to perform date comparison queries?
- how to get the time interval of a date and a datetime displayed as day,hour, min,seconds in sql
- DateTime.Now.ToString("HH:MM") allways gives 20:06
- How can I get the ctime and/or mtime of a file in Python including timezone?
- add time (char(8)) to date column
- MyBatis cannot work with joda DateTime?
- PHP Fatal error: Call to a member function format() on boolean
- Use DateTime format in a class but restrict time tokens
- Modify records to account for correct priority and order between two systems
Related Questions in LOCALIZATION
- Sorting and Grouping of Korean Character (Not familiar with Korean language)
- How to change keyboard language programmatically in windows 8
- Issues using Localize.js and AngularJs
- Multiple language support in Universal App
- InstallShield exclude files based on language selection
- Building Resource-Only DLL (With al.exe) Is Raising "assembly is built by a runtime newer than the currently loaded runtime"
- Angular translate: overriding preferredLanguage in controller
- Android soft keyboard in Chinese languages
- Is short name returned in response from google places api unique?
- Verify Localizable.strings files contain the same keys
- ToLower vs ToLowerInvariant
- Change fmt:formatDate pattern dynamically
- Can not change text when using Localization Sencha ExtJs
- Force VBA to use British localisation
- Passing This(of my main form) to a class that handles direction change/and language change c#/Winforms
Related Questions in UTC
- Time not getting converted to local time properly via moment.js
- What is a good practice when we need to work with datetime
- java.time in Scala - Getting UTC offset from Time Zone
- JavaScript getTimezoneOffset() method in Golang
- Convert date from yyyy-mm-dd to utc format
- Globalizing date & time format in MVC
- need to convert UTC time to current timezone of device
- How does the (Oracle) Java JVM know a leap second is occurring?
- UTC seconds and time format expression convertion in Python
- Why the results of the command 'date -u' command 'date' faster than the result of 25 seconds in linux(centos 5.1)?
- Solr 4.5 not saving time correctly
- PHP Timezone incorrect When using time()
- Calling a function on UTC time
- Index 11 from Calendar prints months in string as "January"
- Convert server time zone to local time zone in Crystal Reports
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There are benefits and drawbacks of each approach.
Server Side
You'll need to know the user's time zone. Usually this is done via user selection on some settings page within your app. Once you know the time zone, conversions usually done with
TimeZoneInfoor with Noda Time, in your MVC controller.You'll need to know the user's culture (ex.
en-USorfr-FR, etc.) to display the correct format (ex.MM/dd/yyyyvsdd/MM/yyyy). This can be done via .NET globalization. The formatting should be done in your MVC view, not the controller.You'll need to stay on top of time zone updates, as time zones rules can change as the governments of the world change their minds about their offsets and DST transition dates.
Client Side
You'll send just the UTC time to the browser, and let it convert to whatever the local time zone is. No need for the user to choose - as long as you only care about their current local time zone.
Getting the formatting right can still be tricky. Libraries like moment.js can help.
There are some bugs that may or may not affect your conversions. Be aware of them.
With regard to your question about the invariant culture - you would need to elaborate on what you mean by "save the date". If you mean storing to a database, such as SQL Server, the culture and format are irrelevant. Send a
DateTimeto your database, not a string.