How getTime works

4

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

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

How much time do I have on this count? How much would this amount give? * 2 * 60 * 60 * 1000 and how can I manipulate the value for 5 minutes?

    
asked by anonymous 04.12.2016 / 01:32

1 answer

8

The measure is in milliseconds.

Looking at this expression, you can see that 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 5 minutes, this would be:

date.setTime(date.getTime()+(5*60*1000));
    
04.12.2016 / 01:34