Results 1 to 16 of 16

Thread: get build time and Date

  1. #1
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default get build time and Date

    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 ...

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: get build time and Date

    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.

  3. #3
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: get build time and Date

    while running the program i want to display in our widget at which time and date is compiling ....

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

    Default Re: get build time and Date

    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.


  5. #5
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: get build time and Date

    I required in qt

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

    Default Re: get build time and Date

    Quote Originally Posted by mouni View Post
    I required in qt
    double-facepalm.jpg

    So you are not using a c++ compiler?
    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.


  7. The following user says thank you to wysota for this useful post:

    d_stranz (29th April 2015)

  8. #7
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: get build time and Date

    i am using c++ compiler

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

    Default Re: get build time and Date

    Quote Originally Posted by mouni View Post
    i am using c++ compiler
    So macros defined in C++ standard will work for you.
    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.


  10. #9
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: get build time and Date

    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....

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

    Default Re: get build time and Date

    Did you use __DATE__ and __TIME__ macros as I advised?
    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.


  12. #11
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: get build time and Date

    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:
    1. -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.

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

    Default Re: get build time and Date

    Quote Originally Posted by Radek View Post
    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.
    __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:
    1. #include <QtDebug>
    2.  
    3. int main() {
    4. qDebug() << __DATE__ << __TIME__;
    5. return 0;
    6. }
    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
    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.


  14. #13
    Join Date
    Sep 2014
    Posts
    94
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: get build time and Date

    working fine but it is showing in 24 hour format...it should show in 12 hour format ...can tell me how to set...

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

    Default Re: get build time and Date

    Quote Originally Posted by mouni View Post
    working fine but it is showing in 24 hour format...it should show in 12 hour format ...can tell me how to set...
    I told you in the other thread.
    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.


  16. #15
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,316
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: get build time and Date

    I told you in the other thread.
    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.

  17. #16
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: get build time and Date

    Quote Originally Posted by d_stranz View Post
    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.
    Perhaps a fourth thread is needed for both of you to re-post your answers so that we have everything in one thread??? ha!

Similar Threads

  1. Date Time
    By javed_alam786 in forum Qt Programming
    Replies: 2
    Last Post: 11th May 2011, 14:52
  2. other time...can't get date
    By mmm286 in forum Newbie
    Replies: 7
    Last Post: 4th March 2010, 15:53
  3. Date and Time format.
    By kaushal_gaurav in forum Qt Programming
    Replies: 3
    Last Post: 12th August 2008, 11:36
  4. Date Time
    By starcontrol in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2008, 11:02
  5. date-time problem
    By aegis in forum Qt Programming
    Replies: 5
    Last Post: 11th February 2007, 18:45

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.