12 lines
507 B
JavaScript
12 lines
507 B
JavaScript
export function generateUsername(prefix = 'user') {
|
|
const now = new Date();
|
|
const YYYY = now.getFullYear();
|
|
const MM = String(now.getMonth() + 1).padStart(2, '0');
|
|
const DD = String(now.getDate()).padStart(2, '0');
|
|
const hh = String(now.getHours()).padStart(2, '0');
|
|
const mm = String(now.getMinutes()).padStart(2, '0');
|
|
const ss = String(now.getSeconds()).padStart(2, '0');
|
|
const rand = Math.random().toString(36).slice(2, 6);
|
|
return `${prefix}${YYYY}${MM}${DD}${hh}${mm}${ss}${rand}`;
|
|
}
|