Dealing with timestamps using google.protobuf.Timestamp or as string/uint64.

1,693 views
Skip to first unread message

Oğuz Türkay

unread,
Jun 15, 2022, 2:48:39 PM6/15/22
to grpc.io
I have a table in my database with createdAtupdatedAt, and deletedAt date columns and I want to send them to client in a proper format. I know there is a type for " timestamp" which google provides as google.protobuf.Timestamp. AFAIK when you use google.protobuf.Timestamp you have to format it like this
"{ seconds: 0, nanos: 0 }", and for example if we want to convert it to a JavaScript date object we'd have to do "new Date(seconds * 1000 + Math.round(nanos / 1e6))"

So I was wondering what is the best practice for dealing with timestamp while using gRPC and is sending just the milliseconds  as string or uint64  without separating it into seconds an anti-pattern or bad practice.
Reply all
Reply to author
Forward
0 new messages