| | |
REg: timestamp with milliseconds linux c++
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2008
Posts: 1
Reputation:
Solved Threads: 0
hi all,
i want to generate a timestamp with year,date,month,day,hours,min,seconds,milliseconds.
in my code i generated a time integer with the help of time().
with that integer can i generate timestamp with milliseconds.
sample code:
is it right??(i mean milli seconds calculation)
i am using linux(fc6)
thanks
kriscbe
i want to generate a timestamp with year,date,month,day,hours,min,seconds,milliseconds.
in my code i generated a time integer with the help of time().
with that integer can i generate timestamp with milliseconds.
sample code:
C++ Syntax (Toggle Plain Text)
int len; time_t mytime; presentTimeStamp = 1999999950;//this value is return from time() mytime = presentTimeStamp; struct tm *mytm; mytm=localtime(&mytime); strftime(timeArray,50,"%a, %d %b %Y %H:%M:%S",mytm); //for milli seconds char timearray[20]; int ms = mytime % 1000; sprintf(timearray, ":%03d", ms); // printf("%s\n",timearray); strcat(timeArray,timearray);
i am using linux(fc6)
thanks
kriscbe
Last edited by Tekmaven; Jul 25th, 2008 at 2:04 pm. Reason: Code tags
1. Try http://www.meangene.com/notes/time.html
2. As usually, time_t returned from time(...) is in seconds, not milliseconds.
3. Use code and /code tags to present your codes.
2. As usually, time_t returned from time(...) is in seconds, not milliseconds.
3. Use code and /code tags to present your codes.
![]() |
Other Threads in the C++ Forum
- Previous Thread: Cygwin/GCC to VC8 conversion question
- Next Thread: need help with this.
| Thread Tools | Search this Thread |
api array beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count database delete desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text text-file tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






