Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Date Time in qml

Date Time in qml

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 3.0k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    beemaneni
    wrote on last edited by
    #1

    Hi friends,
    I need to print date and time in qml.I could do that bt nt as i required..Here i expalin u ..

    I need to print date in dd_MM_yyyy(ie.. underscore format).I could not get this work..However i give the format ,independent of that it is printing as dd/MM/yyyy. Here is my code.

    @ QtObject {
    id: dateObj
    property var locale: Qt.locale()
    property date currentDate: new Date()
    property string dateString
    }
    X_onClicked {
    dateObj.dateString = dateObj.currentDate.toLocaleString("MM-dd-yyyy")
    }@

    If anyone Knows,please help me...
    Thanks in advance

    Bala B
    Infinite Computer systems
    Chennai

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      "toLocaleString":http://qt-project.org/doc/qt-5/qml-qtqml-date.html#toLocaleString-method expects locale as first argument so just pass Qt.locale()
      eg.
      @
      Text {
      text :new Date().toLocaleString(Qt.locale(),"MM-dd-yyyy");
      }
      @

      157

      1 Reply Last reply
      0
      • B Offline
        B Offline
        beemaneni
        wrote on last edited by
        #3

        thanks p3c0..Its working nw..:-)

        Bala B
        Infinite Computer systems
        Chennai

        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