OverviewFelgo 2 Support (Qt 5) › Problem with date.toLocaleString with locale and options

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #19428



    I’m trying to get the following to diplay the date and time without the timezone:

    var d = new Date()

    which currently returns

    ”Friday, June 1, 2018 9:17:44 AM Alaskan Daylight Time”.

    I’d like to change how this is returned, primarily I want to remove the timezone information. However, when I try to use options as described at, I get an invalid date format error.

    If I do something like (but with all the output I want)

    console.debug(d.toLocaleString(Qt.locale(“en-US”), “M-yyyy”)

    It seems to remove the auto-format that I want from toLocaleString.

    Is there any way to pass options so that only the actual date/time elements I want to display are actually displayed but the auto-format is preserved?

    Thank you,


    Felgo Team


    QML is does not always support JavaScript in 100% the same way as in the browser. For example, the QML toLocaleDateString method for date types does not take options as the second argument, but a format identifier.

    You can have a look at the Qt docs linked above, as well as this example:

     var d = new Date()
          // show date format for locale
          console.log("FORMAT en-US: "+Qt.locale("de-AT").dateTimeFormat())
          console.log("FORMAT de-AT: "+Qt.locale("de-AT").dateTimeFormat())
          // default format
          console.debug(d.toLocaleString(Qt.locale("en-US"), Qt.locale("en-US").dateTimeFormat()))
          console.debug(d.toLocaleString(Qt.locale("de-AT"), Qt.locale("de-AT").dateTimeFormat()))
          // no timezone
          console.debug("No timezone: "+d.toLocaleString(Qt.locale("en-US"),"dddd, d. MMMM yyyy HH:mm:ss"))


Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support