This TypeScript function always returns a random number between min and max (both included):
functiongetRndInteger(): number{ const min = 1; // include const max = 10; // include returnMath.floor(Math.random() * (max - min + 1) ) + min; }
🐹 Date/Datetime
Convert Date object to String YYYYMMDD
functioncurrentYYYMMDD() { const d = newDate(); const year = String(d.getFullYear()); let month = String(d.getMonth() + 1); if (month.length < 2) { month = `0${month}`; } let day = String(d.getDate()); if (day.length < 2) { day = `0${day}`; }
return`${year}${month}${day}`; }
Convert String YYYYMMDD to Date
This is a example to convert String YYYYMMDD to date object:
VULTR provides high performance cloud compute environment for you.
Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour).
In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!