How getTime works

Asked

Viewed 350 times

4

I have 1 cookie script and it has a team system of course.. would like to understand this count:

date.setTime(date.getTime()+(days*2*60*60*1000));

How long do I have in this count? *2*60*60*1000 and how I can manipulate the value for 5 minutes?

1 answer

8


The measure is in thousandths of a second.

Looking at that expression, you can see they were originally days * 24 and not 2.

date.setTime(date.getTime()+(days*24*60*60*1000));
             └─────┬──────┘  └┬─┘└┬┘└┬┘└┬┘└─┬─┘
                   │          │   │  │  │   └─ x 1000 transforma segundos em milisegundos
                   │          │   │  │  └───── x 60   transforma minutos em segundos
                   │          │   │  └──────── x 60   transforma horas em minutos
                   │          │   └─────────── x 24   transforma dias em horas
                   │          └─────────────── quantidade especificada em dias
                   └────────────────────────── contados desde a data atual 

For five minutes, this would be it:

date.setTime(date.getTime()+(5*60*1000));
  • 1

    Thank you very much :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.