Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. How to set timezone for web engine's javascript engine?
Forum Updated to NodeBB v4.3 + New Features

How to set timezone for web engine's javascript engine?

Scheduled Pinned Locked Moved Unsolved QtWebEngine
2 Posts 2 Posters 732 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • VinnieV Offline
    VinnieV Offline
    Vinnie
    wrote on last edited by
    #1

    Current behavior

    • Create a QWebEngineView
    • Visit https://codepen.io/pen/, open the console at the lower left corner
    • Run Date()

    This would show the local system's local time and timezone.

    Question

    How can I tell QWebEngineView to use a different timezone when executing javascript in the browser, instead of using the system timezone?

    JonBJ 1 Reply Last reply
    0
    • VinnieV Vinnie

      Current behavior

      • Create a QWebEngineView
      • Visit https://codepen.io/pen/, open the console at the lower left corner
      • Run Date()

      This would show the local system's local time and timezone.

      Question

      How can I tell QWebEngineView to use a different timezone when executing javascript in the browser, instead of using the system timezone?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Vinnie
      So this is a generic question about JavaScript rather than anything to do specifically with QWebEngine (Chromium). JS allows you to read the current timezone (of the browser) but not set it. You have to do the manipulations in code yourself on a Date object to "emulate" a different tz. Have a read of, e.g. https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved