Results 1 to 3 of 3

Thread: QDate without additional character

  1. #1
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default QDate without additional character

    Hello everybody,

    OS: WinXP
    Compiler: MINGW
    QT: 3.4

    I save the current Datetime in a String variable:
    Qt Code:
    1. QDateTime dt = QDateTime::currentDateTime();
    2. QString datum = dt.toString();
    To copy to clipboard, switch view to plain text mode 
    My Result: "Do 16. Feb 10:00:59 2006"

    I have to remove all "." and ":" from my String. I had a look in the QString class and i found a lot of functions and examples, but not for my case.
    Could somebody help me to open my mind?

    thanks
    Think DigitalGasoline

  2. #2
    Join Date
    Jan 2006
    Posts
    273
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QDate without additional character

    Hi,

    I could solve it

    Qt Code:
    1. QDateTime dt = QDateTime::currentDateTime();
    2. QString datum = dt.toString();
    3.  
    4. datum.replace( ".", " " );
    5. datum.replace( ":", " " );
    To copy to clipboard, switch view to plain text mode 

    thx
    Think DigitalGasoline

  3. #3
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDate without additional character

    Qt Code:
    1. QDateTime dt = QDateTime::currentDateTime();
    2. QString datum = dt.toString("ddd dd MMM hh mm ss yyyy");
    To copy to clipboard, switch view to plain text mode 
    Everything is in the docs did you bother reading them?

Similar Threads

  1. Problems with QDate
    By cyberboy in forum Qt Programming
    Replies: 4
    Last Post: 25th May 2008, 21:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.