| | |
REg: timestamp with milliseconds linux c++
![]() |
•
•
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 |
anyfile api array based binary bitmap c++ c/c++ char class classes code coding compile console conversion count delete deploy desktop developer directshow dll download draw dynamic dynamiccharacterarray email encryption error file forms fstream function functions game gdi+ givemetehcodez gnu graph gui homeworkhelp homeworkhelper http iamthwee ibm ifstream input int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node number numbertoword output packing parameter pointer problem program programming project python random read recursion reference rpg string strings temperature template test text text-file tree url variable vector video visualc++ visualizationtoolkit win32 windows winsock word wordfrequency wxwidgets






