Want to get system time...how?

This is a discussion on Want to get system time...how? within the C++ Programming forums, part of the General Programming Boards category; Hey Guys, I was wondering if anyone can help me, I wanted to get the date (or year) from the ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    40

    Want to get system time...how?

    Hey Guys,
    I was wondering if anyone can help me, I wanted to get the date (or year) from the system so I can calculate something like age, or get a variable to change (inc or dec)
    everyday or certain period, is that possible, through certain functions like time() (which I don't know how it works), and how do I use them..

    Thanks for the time you took to read my post....any help would be appericiated.

  2. #2
    -bleh-
    Join Date
    Aug 2010
    Location
    somewhere in this universe
    Posts
    458
    boost::date_time would solve your problem.
    "All that we see or seem
    Is but a dream within a dream." - Poe

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    40
    Hello nimitzhunter,
    I don't know if you have noticed but I am a complete noob, so if you can explain just
    a little bit, that would be great.......Thanks

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Use the localtime() function.
    There's an example on that page.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  5. #5
    Registered User
    Join Date
    Feb 2011
    Posts
    40
    Hello cpjust;
    Thanks for the links, but I have a problem, when ever I copy the code into my IDE
    (Bloodshed Dev-C++) it runs an old DOS or command prompt window I tried it for localtime, ctime with the same result, and I just wanted to ask, What is going on??

  6. #6
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    682
    What code? What about providing some more information, since we have no idea what you did?
    I never put signature, but I decided to make an exception.

  7. #7
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    If your question is "why did a command prompt window open", the answer is "that's what you want to have happen", since you are (presumably) writing a console program. If you mean something else, you'll have to tell us what it is.

  8. #8
    Registered User
    Join Date
    Feb 2011
    Posts
    40
    I am Terbly sorry guys I miswrote it, what I meant was it opened a previously compiled source code's DOS.
    You see.......
    I compiled a programme long time ago, and it ran normally on the DOS like app. and now after long time I copied the code of the local time in to the IDE, compiled with no errors and then displayed that old DOS window from the other programme, I cant see any relation between the two codes or any obviousreason for this to happen.
    I hope I made myself clearer.

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    If you copied the code, the executable should look exactly the same as before.

  10. #10
    Registered User
    Join Date
    Feb 2011
    Posts
    40
    Finally, the localtime code worked! I guess it was a compilor mistake or something.
    ..............thanks guys

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Time for a new system....again
    By VirtualAce in forum Tech Board
    Replies: 6
    Last Post: 06-18-2007, 07:48 AM
  2. time of system
    By arian in forum C++ Programming
    Replies: 3
    Last Post: 12-10-2003, 12:51 PM
  3. System Time
    By Leeman_s in forum C++ Programming
    Replies: 2
    Last Post: 05-23-2003, 07:45 PM
  4. System Time
    By MethodMan in forum C Programming
    Replies: 4
    Last Post: 03-16-2003, 02:07 PM
  5. system time
    By jpre in forum C++ Programming
    Replies: 2
    Last Post: 09-29-2001, 10:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21