diff --git a/types/known/timestamppb/timestamp.go b/types/known/timestamppb/timestamp.go index 11960893..2c72e3b6 100644 --- a/types/known/timestamppb/timestamp.go +++ b/types/known/timestamppb/timestamp.go @@ -17,6 +17,13 @@ func ToTimestamp(t time.Time) *Timestamp { return New(t) } +// FromUnixMilli constructs a new Timestamp from the provided unix milliseconds value. +// +// Example: time.Now().UnixMilli() +func FromUnixMilli(timestampUnixMilli int64) *Timestamp { + return New(time.UnixMilli(timestampUnixMilli)) +} + // GetEmpty checks if the timestamp is empty. func (x *Timestamp) GetEmpty() bool { return x.SizeVT() == 0