PDA

View Full Version : Generate a file with Datetime



StarRocks
19th January 2013, 07:18
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,

Lykurg
19th January 2013, 07:44
See QDateTime and use it where you define the file name.

StarRocks
19th January 2013, 09:25
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,

d_stranz
19th January 2013, 18:04
QFile file("/home/venugopal/"+s+""+dateTimeString+".xml");


This doesn't work for me. My PC does not have a directory named "/home/venugopal/".

Boron
19th January 2013, 18:19
Then replace "/home/venugopal/" with a directory of your choice ;) (a directory that exists on your PC of course).
:o

d_stranz
19th January 2013, 19:23
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?

;)

wysota
19th January 2013, 21:55
Is it something related to hacking into 127.0.0.1?