Can the length of current Unix timestamp greater then 10 Digits
Asked Answered
B

2

5

My Question Is :

Is The time() [10 Digits Number (Seconds)] can Be Increased to 11 or 12 digits ?

The Purpose of Asking This Question is I am creating A uniq transaction id depending on that and with some other variable.. I have to maintain a Length of 18 Digits (Numbers only)

Edit : Note I dont want to make it longer.. As it increases to 11/12 digits i have to make the rest 7/8 digits dynamically .. Because i am using 2 randomiser for that last 7/8 digits

Edit2: Will it make sense => rand(8 Digits) vs rand(3) + rand(3) + rand(2) For Collision Purpose ??

Burney answered 7/5, 2020 at 12:49 Comment(6)
...can Be Increased to 11 or 12 digits .... Of course it will increase...but in many many many years in the future - Note time() returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).Checklist
@B001ᛦ Yes that is what i want to know cause if it increases to 11/12 i have to maintain the rest 8/7 digits dynamicallyBurney
Yes, in Saturday, 20 November 2286 y., 17:46:40 GMTJeanniejeannine
Thanks! Please see the Edit 2Burney
I find your expected output to be Unclear. Is this an XY Problem?Deadandalive
@Deadandalive i did't get itBurney
S
9

If you run date() with a time parameter containing the first 11 digit time you will see that you will not get 11 digits in a time() until

echo date('d/m/Y H:i:s', 10000000000);

RESULT

20/11/2286 17:46:40

If you think that your App will be running after that date you should worry about this situation, otherwise you dont need to worry or code for it.

PS I doubt PHP will exist or Intel come to that in 2286 :)

Skiing answered 7/5, 2020 at 13:26 Comment(2)
Hey I want to know another thing that if i use two 4 digits randomiser against 1 8 digit randomiser.. Will it be better for uniqness or it makes no sense ?? I dont know the logic properlyBurney
You are likely to get less duplicates with an 8 char random number than with a 4 char. But you may still get duplicatesSkiing
H
0

You do not have control over the function time(), it admits no parameters. If you need to make it longer, you could prepend one or two 0 to the timestamp.

Hus answered 7/5, 2020 at 12:55 Comment(1)
I dont want to make it longer ! As if it increases to 11/12 i have to make athe rest 8/7 digits dynamicallyBurney

© 2022 - 2024 — McMap. All rights reserved.