Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix timestamp on visual c++

Status
Not open for further replies.

datapath

Programmer
Feb 20, 2003
11
0
0
BR
Hello,

how can I get the unix timestamp of the present time on visual c++?

Thanks.
 
"the present time": at run-time or at compile-time?

"unix timestamp": not sure what you mean by this? Do you mean a Unix timestamp format?

I suspect you want the [tt]__TIME__[/tt] and [tt]__DATE__[/tt] predefined macros (if you want the compile-time information; or the [tt]asctime()[/tt] function (from [tt]time.h[/tt]) if you want it at run-time.

________________________________________
[hippy]Roger J Coult; Grimsby, UK
In the game of life the dice have an odd number of sides.
 
I need the time at run-time, and unix timestamp is the number of seconds elapsed since 00:00, january 1, 1970.

I think that the standard C function "time" is implemented in visual c++ and will do it for me. Gonna try it.

Thanks for your attention.
 
If it's anything to do with MS, it probably counts from January 1980.

rgds
Zeit.
 
Sorry that this is a bit blunt:

If you had an idea about the [tt]time[/tt] function, datapath, why ask the question you did. I looked at the documentation and found this:
__________________________________________________________
time

Gets the system time.
Code:
   time_t time( time_t *timer );

Routine: [tt]time[/tt]
Required Header: [tt]<time.h>[/tt]
Compatibility: ANSI, Win 95, Win NT

Return Value

[tt]time[/tt] returns the time in elapsed seconds. There is no error return.

Parameter

[tt]timer[/tt] -- Storage location for time

Remarks

The [tt]time[/tt] function returns the number of seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time, according to the system clock. The return value is stored in the location given by [tt]timer[/tt]. This parameter may be [tt]NULL[/tt], in which case the return value is not stored.
__________________________________________________________

Seems it does exactly what you want.


________________________________________
[hippy]Roger J Coult; Grimsby, UK
In the game of life the dice have an odd number of sides.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top