Hi friends..
I am compiling application i want to display compile at which time and date....
help me to solve ...
can any body send example code ...
Hi friends..
I am compiling application i want to display compile at which time and date....
help me to solve ...
can any body send example code ...
1. Look at clock
2. Type time into source code that "display compile time"
3. Compile
4. Profit
You provide us with no useful information that might lead to a better answer.
while running the program i want to display in our widget at which time and date is compiling ....
I required in qt
d_stranz (29th April 2015)
i am using c++ compiler
when i compiled program exe file created.
in that example i added a dialog box in that i am showing version and time.... when it complied ...
after that 4 hours i run excutable it is showing current time it should show when i compiled program that time should be replied...
the excutable is in release mode....
It depends on the operating system (windows in your case) and the compiler. I do not know any standard function which would provide the build time. __DATE__ and __TIME__ are useless because they provide the current date and time.
In Linux (not in windows) I would try the "backward apostrophes" ability of bash. Define a macro COMPTIME on the command line of the compiler:
Qt Code:
-D COMPTIME=`date +"\"%F\""`To copy to clipboard, switch view to plain text mode
The thing between ` ` is a shell command displaying date and time. Because of ` ` the output (the date and time) will replace the command in ` ` on the command line. This way, the COMPTIME will be set to the time of compilation. The code can use COMPTIME for outputting the build time.
If you can do something similar in windows, try it.
__DATE__ and __TIME__ return date and time when the preprocessor was ran, so it's not current time but rather the time when the file is compiled.
Qt Code:
#include <QtDebug> int main() { qDebug() << __DATE__ << __TIME__; return 0; }To copy to clipboard, switch view to plain text mode
wysota@localhost:/tmp/b$ ./b
Apr 30 2015 10:55:37
wysota@localhost:/tmp/b$ ./b
Apr 30 2015 10:55:37
wysota@localhost:/tmp/b$ ./b
Apr 30 2015 10:55:37
wysota@localhost:/tmp/b$ ./b
Apr 30 2015 10:55:37
wysota@localhost:/tmp/b$ LC_ALL=C date
Thu Apr 30 10:56:46 CEST 2015
wysota@localhost:/tmp/b$ ./b
Apr 30 2015 10:55:37
working fine but it is showing in 24 hour format...it should show in 12 hour format ...can tell me how to set...
Your answer there was unsatisfactory, that's why he asked again. My answer in the other thread will probably also turn out to be unsatisfactory.I told you in the other thread.
Bookmarks