Results 1 to 4 of 4

Thread: Date and Time format.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    May 2008
    Location
    Rijeka, Croatia
    Posts
    85
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    10
    Thanked 6 Times in 6 Posts

    Default Re: Date and Time format.

    Use daysTo function:
    Qt Code:
    1. QDate _Today=QDate::currentDate();
    2. QDate _SomeDate(2008,8,12);
    3. QString _Day;
    4. qint32 _Difference = _Today.daysTo(_SomeDate)
    5. switch(_Difference)
    6. {
    7. case -1:
    8. _Day="Yesterday";
    9. break;
    10. case 0:
    11. _Day="Today";
    12. break;
    13. case 1:
    14. _Day="Tomorrow";
    15. break;
    16. default:
    17. _Day=_SomeDate.toString("dd mmm");
    18. break
    19. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to stefan for this useful post:

    kaushal_gaurav (12th August 2008)

Similar Threads

  1. time and date issues
    By boog07005 in forum Newbie
    Replies: 5
    Last Post: 20th August 2012, 15:15
  2. automatic time and date updating
    By sudheer in forum Qt Tools
    Replies: 1
    Last Post: 17th January 2008, 10:00
  3. to set date and time in the file info of two days back
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 11th October 2007, 16:54
  4. chage date and time
    By behnia_k in forum General Programming
    Replies: 4
    Last Post: 18th July 2007, 12:48
  5. QDateTime GMT add sec. or - sec. from locale time....
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 20th February 2007, 16:39

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
  •  
Qt is a trademark of The Qt Company.