MCPcopy Index your code
hub / github.com/RandomAPI/Randomuser.me-Node / getDateTime

Function getDateTime

util.js:1–12  ·  view source on GitHub ↗
(daysBack = 0)

Source from the content-addressed store, hash-verified

1function getDateTime(daysBack = 0) {
2 const date = new Date(new Date().getTime() - 86400000 * daysBack);
3 const year = date.getFullYear();
4
5 let month = date.getMonth() + 1;
6 month = (month < 10 ? '0' : '') + month;
7
8 let day = date.getDate();
9 day = (day < 10 ? '0' : '') + day;
10
11 return year + '-' + pad(month, 2) + '-' + pad(day, 2);
12}
13
14function pad(n, width, z) {
15 z = z || '0';

Callers

nothing calls this directly

Calls 1

padFunction · 0.85

Tested by

no test coverage detected