hi all......
Can you explain me how to get local timestamp in C++.
regards wijitha.

see the functions in time.h -- such as time(0) will return the current time in seconds since 1970 (or something like that). Then localtime() will convert it to a structure tm. There is also a gmtime() that converts the time(0) to GMT instead of local time.

commented: Nice succinct answer +12

hi...
i want to get local time stamp in format mmddhhmmsshh where last hh gives the hundreds of seconds.
if you have any idea reply me.
regards
wijitha

You have to format the stamp yourself from the information received from the functions Ancient Dragon suggested you look into.

hi...
i want to get local time stamp in format mmddhhmmsshh where last hh gives the hundreds of seconds.
if you have any idea reply me.
regards
wijitha

The functions in time.h will not give you milliseconds. For that you need to call other os-specific functions. For MS-Windows you can call the win32 api GetSystemTime() which fills in a structure for you and, on most Windows systems, will give you milliseconds. After you call that function you will have to format the information however you want it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.