Results 1 to 7 of 7

Thread: Generate a file with Datetime

  1. #1
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Generate a file with Datetime

    Dear Forums,


    I have a doubt regarding how to save a file/generate a file with datetime....I have generated a file but i want it to save with the current datetime.....Please let me know if theres any solution.........Thanks in Advance.....


    Regards,

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Generate a file with Datetime

    See QDateTime and use it where you define the file name.

  3. #3
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Red face Re: Generate a file with Datetime

    Dear Forums,


    Thanks for the reply.........This is the code to be used for having the datetime for a file........


    QDateTime dateTime = QDateTime::currentDateTime();
    QString dateTimeString = dateTime.toString("hh_mm_ss yyyy_MMM_dd");

    QFile file("/home/venugopal/"+s+""+dateTimeString+".xml");



    Regards,

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,530
    Thanks
    253
    Thanked 722 Times in 712 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Generate a file with Datetime

    QFile file("/home/venugopal/"+s+""+dateTimeString+".xml");
    This doesn't work for me. My PC does not have a directory named "/home/venugopal/".

  5. #5
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Generate a file with Datetime

    Then replace "/home/venugopal/" with a directory of your choice (a directory that exists on your PC of course).

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,530
    Thanks
    253
    Thanked 722 Times in 712 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Generate a file with Datetime

    Oh.... I get it..... I created that folder so I could make this work..... So it is OK to delete that? What do I do with all those XML files?


  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Generate a file with Datetime

    Is it something related to hacking into 127.0.0.1?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. how to generate sis file with qt
    By fareenafatima in forum Newbie
    Replies: 2
    Last Post: 27th February 2011, 18:53
  2. how to generate a PDF file with qt?
    By ghnie in forum Qt Programming
    Replies: 1
    Last Post: 25th March 2010, 07:23
  3. cannot generate exe file in haique
    By anishpaily in forum Qt Tools
    Replies: 6
    Last Post: 15th October 2008, 08:27
  4. how to generate debug file???
    By sudheer in forum Qt Tools
    Replies: 2
    Last Post: 1st May 2008, 23:03
  5. how can i generate .cpp file in QT 4.3.0
    By gamitkumar in forum General Programming
    Replies: 4
    Last Post: 3rd September 2007, 22:23

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.