From server I'm getting timestamp like this: " 2022-12-21 16:47:10 ". And I want to convert this time to local time zone, depends on client. E.g. 16:47:10 in Poland was 10am in US. Any ideas how to achieve that? I'm using Vue framework.
How to convert timestamp, depends on user timezone?
67 Views Asked by Raf1k At
1
There are 1 best solutions below
Related Questions in JAVASCRIPT
- Using Puppeteer to scrape a public API only when the data changes
- inline SVG text (js)
- An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
- Storing the preferred font-size in localStorage
- Simple movie API request not showing up in the console log
- Authenticate Flask rest API
- Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
- How to request administrator rights?
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- In Datatables, start value resets to 0, when column sorting
- How do I link two models in mongoose?
- parameter values only being sent to certain columns in google sheet?
- Run main several times of wasm in browser
- Variable inside a Variable, not updating
Related Questions in VUE.JS
- Problems with matter.js and i18n in vue.js
- Form Validation not working in custom component Vue
- Authenticating vue app on each route change
- Vue/TailwindCSS - Content is behind Sidebar
- Vue3 Suspense Parent > Child Animation
- Pass dynamic object data via nuxt-link to component
- Failed to resolve import, but the path is valid, and detected as such by VSCode
- how to use less variables in vue components?
- Prevent a webpage from navigating away
- Creating a modal window in product edit page in Shopware6 and saving data to custom table(repository) from a form within the modal window
- How do I fix (or ignore) a TypeScript error that's inside a HTML template?
- Vue.js Checkbox Alignment Issue: Centering Checkboxes Within Table Cells
- How to reset vue product filter?
- Vue display output of two dimensional array
- vue js error when adding bonus items to another item
Related Questions in TIMESTAMP
- Laravel's whereBetween method not working with two timestamps
- TimeStamp on ICMP on Scapy (Python)
- How to properly set timestamp field seeder for a postgreSql database in Laravel 10.47?
- Hive query on HUE shows different timestamp than programatically/on data
- Invalid argument with SendMsg() cmsg in golang
- C# DateTime.Parse method losses nanosecond precision of the timestamp string
- How can I keep randomized UNIX timestamp in specific hour range in SQL?
- How to edit the Samsung Trailer Tag "Timestamp"
- How can I find the elapsed time from a specific date to now when using Pandas Timestamp in Python?
- How to customize tick mark for 2D surface plotply in both x axis (time of day) & y axis (dates in a year)
- How to set the display format of timestamp in Apache IoTDB to yyyy-MM-dd HH:mm:ss.SSSZZ?
- How to print out a datetime stamp info in a plpgSQL using "raise info" function for debugging purpose in Redshift environment
- string to timestamp with sql
- How can I 'tell' PostgreSQL what the timestamp format is when I INSERT a text string that represents a timestamp into a table?
- Unable to write the file while using windowing for streaming data use to ":" in Windows
Related Questions in TIMEZONE
- I'd like to create a custom time zone converter, any pointers?
- ValueError: setting an array element with a sequence. Trying to make a Skymap in Python
- Timezone Issue with Clickhouse - Asia/Tehran Timezone
- Hive query on HUE shows different timestamp than programatically/on data
- datetime.datetime.now returning "received a naive datetime while time zone support is active"
- calendar keeps showing the wrong time
- unable to update the Google Cloud SQL TimeZone without re-creating the instances
- Identifying invalid dates in Oracle database due to daylight saving time changes
- Timestamp with timezone: works with isql but not with DBD::Firebird
- Django how do I use system timezone?
- How do I fix my timezone issues on my R Shiny App? Unrecognized time zone 'GMT+5'
- How do I convert an epoch into a datetime, taking into account the time zone?
- How to change Postgres timezone
- Time Zones and Daylight Savings Time on restricted server
- Outputting two variables on a single line without changes to the variables
Related Questions in LOCALTIME
- How to fix the non-updating clock on a tkinter weather app?
- Parse a datetime string that has no 'T' separator using java.time
- Converting UTC to Local Time with daylight saving in Java
- How to save time (Localtime) from WheelTimePicker on API 24?
- Convert Date to UTC DateTime
- LocalTime truncating trailing 00 values
- Is there any date/time function that handles tomorrow's date including carry over into next month?
- Can't get right time in C with localtime()?
- localtime() giving the wrong date in C
- Is there a way to set alarm in android with local date and local time?
- How to convert timestamp, depends on user timezone?
- How to get the current time in a different city in C?
- Why is Java LocalTime 01:32:13.283256 stored as time 00:32:13 in database? 1 hour behind
- Java int formating?
- HQL query: filtering LocalDateTime property by LocalTime
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?
That represents a date and a time without any time zone or offset. There's no way to tell that it is from Poland from this data alone.
Thus, the first part of your solution would be to change the server-side code to do one of the following:
Emit the time in terms of UTC. For example:
"2022-12-21T15:47:10Z". In many cases this is the best choice, especially if your timestamps don't have any meaningful relationship to a local time zone.Emit the time in terms of a local time, including the time zone offset for that point in time in that time zone. For example, if indeed the value is from Poland, then the server should emit
"2022-12-21T16:47:10+01:00"because Poland is one hour ahead of UTC at that date and time.Emit the time in terms of local time, but include a time zone identifier in a separate field. For example:
However, this approach could have ambiguities during a backward transition, such as when daylight saving time ends.
Combine the previous two options to resolve ambiguities:
This is the most complete form of the data, but generally should only be necessary if your use case is related to scheduling of future events.
For more on use cases for the options above, read DateTime vs DateTimeOffset, which was written for .NET but applies here as well.
As far as the client-side JavaScript goes, for either of the first two options, you can pass the inputs directly to the
Dateobject's constructor, then use methods liketoStringortoLocaleString. You can also use that approach for thedatetimeportion of the fourth option.For the third option though, you'll need to use a library such as Luxon to handle the input time zone identifier. The
Dateobject cannot accept a time zone identifier as input presently. (There is atimeZoneoption ontoLocaleString, but that is for output, not input.)For example: