Formatting milliseconds as days, hours, minutes, and seconds This is a function which aims to convert an amount of milliseconds to a more human-interpretable Day(s) Hour(s) Minute(s) Second(s) format:

function dhms(t) {
    d = Math.floor(t / (1000 * 60 * 60 * 24)),
    h = Math.floor((t % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
    m = Math.floor((t % (1000 * 60 * 60)) / (1000 * 60)),
    s = Math.floor((t % (1000 * 60)) / 1000);
    return d + 'Day(s) ' + h + 'Hour(s) ' + m + 'Minute(s) ' + s + 'Second(s)'
}


So for getting the variables values I have for now something quite verbose:

d = Math.floor(t / (1000 * 60 * 60 * 24)),
h = Math.floor((t % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
m = Math.floor((t % (1000 * 60 * 60)) / (1000 * 60)),
s = Math.floor((t % (1000 * 60)) / 1000);


Is it the way to go? Or should I go with:

d = Math.floor(t / 86400000), 
h = Math.floor(t % 86400000 / 3600000), 
m = Math.floor(t % 3600000 / 60000), 
s = Math.floor(t % 60000 / 1000);


Or even with:

d = Math.floor(t / 864e5), 
h = Math.floor(t % 864e5 / 36e5), 
m = Math.floor(t % 36e5 / 6e4), 
s = Math.floor(t % 6e4 / 1e3);


Or another way? How is it recommended to assign time values?
The Decimal Point

Exponential notation is by far the better for large numbers.

However when writing numbers in this format the convention is to have the decimal point after the first digit, as the exponent represents the magnitude of the value which is obscured if you have to locate the decimal point.

d = Math.floor(t / 8.64e7), 
h = Math.floor(t % 8.64e7 / 3.6e6), 
m = Math.floor(t % 3.6e6 / 6e4), 
s = Math.floor(t % 6e4 / 1e3);


As constants

But.. These are magic numbers, and you repeat some of them several times, which is prone to error. Also assuming that this function would be part of a set of such functions declaring these constants as named variables would be much better.

DAY_MS = 8.64e7;
HOUR_MS = 3.6e6;
MIN_MS = 6e4;
SEC_MS = 1e3;


Derived values

As they are derived from each other you can then write it as

SEC_MS = 1e3;
MIN_MS = SEC_MS * 60;
HOUR_MS = MIN_MS * 60;
DAY_MS = HOUR_MS * 24;


Encapsulate

If you then encapsulate them you can drop the _MS and your function would look like.

"use strict";
const dhms = (()=&gt;{
    const SEC = 1e3;
    const MIN = SEC * 60;
    const HOUR = MIN * 60;
    const DAY = HOUR * 24;
    return time =&gt; {
        const ms = Math.abs(time);
        const d = ms / DAY | 0;
        const h = ms % DAY / HOUR | 0;
        const m = ms % HOUR / MIN | 0;
        const s = ms % MIN / SEC | 0;
        return `${time &lt; 0 ? "-" : ""}${d}Day(s) ${h}Hour(s) ${m}Minute(s) ${s}Second(s)`;
    };
})();


Notes


That t is made positive ms to avoid a negative sign on each number. This also lets you use the shorter and quicker | 0 (bit-wise OR 0) to floor the values, which you should only use for positive integers.
The use of a template string to format the output.
You could also define it as a module and thus avoid the need to encapsulate the constants as a module has its own local scope.