Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show message timestamp as UTC ISO8601 format #189

Open
MitchelNijdam-Rockstars opened this issue Jul 1, 2019 · 5 comments · May be fixed by #351
Open

Show message timestamp as UTC ISO8601 format #189

MitchelNijdam-Rockstars opened this issue Jul 1, 2019 · 5 comments · May be fixed by #351

Comments

@MitchelNijdam-Rockstars
Copy link

Although I think currently the %T format string token just prints the unix epoch timestamp as read from kafka, for quick debug purposes it would be very useful to have a timestamp in more readable format, for example ISO8601 in UTC. Currently I have to copy paste the timestamps to a converter in order to make sense of it.

If there already is an alternative I'm happy to hear about it!

@edenhill
Copy link
Owner

edenhill commented Oct 7, 2019

That does make sense.

As a workaround you can use jq to reformat the timestamp: https://stackoverflow.com/questions/36853202/jq-dates-and-unix-timestamps

@wkujawa
Copy link

wkujawa commented Dec 14, 2019

I have done a quick change #216 to display human readable form next to epoch. You can build it from https://github.com/wkujawa/kafkacat

Example for format 'Timestamp: %T':
Timestamp: 1576098689443 (Wed 2019-12-11 22:11:29.443 CET)

It should be new format specifier but that way is good for me. Feel free to do whatever you like with it. I can also modify it further.

@fletchgqc
Copy link

fletchgqc commented Jun 14, 2022

Example of the workaround mentioned by @edenhill:

kcat -C \
  -b $KAFKA_BROKER \
  -t $KAFKA_TOPIC \
  -o beginning \
  -J \
  -e \
| jq '.ts |= (. / 1000 | strftime("%Y-%m-%d %H:%M:%S"))'

Edit: fixed according to the comments directly below

@raphaelsolarski
Copy link

Example of the workaround mentioned by @edenhill:

kcat -C \
  -b $KAFKA_BROKER \
  -t $KAFKA_TOPIC \
  -o beginning \
  -J \
  -e \
| jq '.ts |= (. / 1000 | strftime("%Y-%m-%d %H:%m:%S"))'

@fletchgqc @edenhill Thanks a lot. btw. you probably meant "%Y-%m-%d %H:%M:%S"

@tbrv
Copy link

tbrv commented Jul 26, 2023

For anyone who, like me, has trouble seeing the difference: the original comment by @fletchgqc erroneously uses m (month) not M (minute) for the time format

--------------Δ----
"%Y-%m-%d %H:%m:%S"
"%Y-%m-%d %H:%M:%S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants