Skip to content
Discussion options

You must be logged in to vote

The way you are doing it is the best way I can think of.

I'm not quite sure what the issue is with padding the number? Given that it is over 250 years until the string length of the unix timestamp will take another digit, you should just be able to prepend the required number of zeros without worrying about increasing the length of the resulting string.

$ "000" + to_string(9_999_999_999 - to_unix_timestamp(now()))
"0008313431890"

Presumably you will want to round the timestamp to avoid creating a new object every second.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@alanwguo
Comment options

@srstrickland
Comment options

Answer selected by alanwguo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants