Archived

This topic is now archived and is closed to further replies.

Retrieveing time.

This topic is 5046 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a way to get just the time. no date?
#include <time.h>
#include <iostream.h>
int main()
{
  time_t hold_time;
  hold_time=time(NULL);
  cout<<"The date is: "<<ctime(&hold_time);
}
[\source]

This is the only thing I could find but not sure how to get JUST the time of day out of it.
Technology can either save us or destroy us. Me ... I say it will destroy us if Microsoft is the example.

Share this post


Link to post
Share on other sites
gettimeofday()

EDIT: actually, localtime(), if you don't want to do as much work yourself.


"Sneftel is correct, if rather vulgar." --Flarelocke

[edited by - sneftel on February 22, 2004 1:36:19 AM]

Share this post


Link to post
Share on other sites
Thanx, but that gives the same information as what I put. I'm looking to see how to pull the hour only from the before it get's convertid into 12 hour but I'm kind of new and they don't put many coments in the header files I got. All the help I found on the web only shows the 'as-is', not how to look at a spicifics sperate. (month, day, hour, min, sec, ect. all in seperate outputs.)

Technology can either save us or destroy us. Me ... I say it will destroy us if Microsoft is the example.

[edited by - Xeneth on February 22, 2004 9:26:54 AM]

Share this post


Link to post
Share on other sites
This is starting to get annoying. I can't understand this. How can I get the hour of day while still in 24H format? If I can't figure this out, I'm going to have to cut that part of the game out for later, but that will Sieriously cut into the fun. If you know how to do this, Please post a sample code I can look at.

Technology can either save us or destroy us. Me ... I say it will destroy us if Microsoft is the example.

[edited by - Xeneth on February 22, 2004 10:54:13 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by Xeneth
Thanx, but that gives the same information as what I put. I''m looking to see how to pull the hour only from the before it get''s convertid into 12 hour but I''m kind of new and they don''t put many coments in the header files I got. All the help I found on the web only shows the ''as-is'', not how to look at a spicifics sperate. (month, day, hour, min, sec, ect. all in seperate outputs.)


look at localtime().


"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites
I''m an idiot. Thanx nobody.

The reason I could never pull tm_hour from the new structure was I was tring o put in the var. like ''struct.variable'' (the code that''s in my testing). I forgot about -> when dealing with a pointer.


Technology can either save us or destroy us. Me ... I say it will destroy us if Microsoft is the example.

Share this post


Link to post
Share on other sites