I'm writing a program that will parse and print packet information from a tcpdump file.

One of the fields is the timestamp, which is in seconds.

The program is reading the timestamp into an unsigned int type.

I need to be able to convert the timestamp in seconds to a normal date/time form.

Any suggestions would be appreciated.


Recommended Answers

All 3 Replies

see the functions in time.h, specifically localtime() or gmtime()

I've tried. The biggest problem I'm having is that when I try to compile it, I get errors such as:

cannot convert ‘unsigned int*’ to ‘time_t*’

So, just typecast it to time_t

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.