Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]DateAndTime
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]DateAndTime

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.9k 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.
  • T Offline
    T Offline
    toho71
    wrote on last edited by
    #1

    I got this string from an xml file:
    <timestamp>2012-02-23T10:32:00.50+01:00</timestamp>

    And I want to split this in the apropriate time and date format.

    I want to have the date in this format 2012-02-23
    And Time in this 10:32:00

    Is the best way to split the string to a string list and parse it to the QDate.fromString();
    The same with time.

    Or Is there away to put this String in a QLocal obj or a QDateTime obj and just take the QDateTIme.date() and time() and get what I want.

    I haven't found this in the docs but it's alitlebit strange because the format is common.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Did you see "QDateTime::fromString":http://developer.qt.nokia.com/doc/qt-4.8/qdatetime.html#fromString and "QDateFormat":http://developer.qt.nokia.com/doc/qt-4.8/qt.html#DateFormat-enum ?

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        d2uriel
        wrote on last edited by
        #3

        You can read "here":http://developer.qt.nokia.com/doc/qt-4.8/qdatetime.html#fromString and "here":http://developer.qt.nokia.com/doc/qt-4.8/qt.html#DateFormat-enum about it.

        Try:
        @QDateTime timeStamp = QDateTime::fromString(yourTimestampString, Qt::ISODate);@

        Edit: Aww, I'm too late ;-).

        "Do not judge, and you will never be mistaken." - Jean-Jacques Rousseau

        1 Reply Last reply
        0
        • T Offline
          T Offline
          toho71
          wrote on last edited by
          #4

          Thank you all for your help.
          Works perfect;

          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