Skip to Content
Formulas and examples

Formulas and examples

Convert timestamp to avatar background color

Formula: (T - timestamp)

\[\begin{align} H &= (T \mod 360) \\ S &= 0.2 + (\frac{T \mod 1000}{1000}) \times 0.4 \end{align} \]

Example: (JavaScript)

const timestampToHSV = (timestamp) => { const h = timestamp % 360; // Hue: 0-360 const s = 0.2 + ((timestamp % 1000) / 1000) * 0.4; // Saturation: 20%-60% const v = 1; // Value: 100% return { h, s, v }; }; const timestamp = 1700000000; // Timestamp in seconds const hsv = timestampToHSV(timestamp); console.log(`HSV(${hsv.h.toFixed(2)}, ${(hsv.s * 100).toFixed(2)}%, ${(hsv.v * 100).toFixed(2)}%)`);