create a time function in typescript

index.ts
function getTime(): string {
    const date: Date = new Date();
    const hours: number = date.getHours();
    const minutes: number = date.getMinutes();
    const seconds: number = date.getSeconds();
    
    return `${hours}:${minutes}:${seconds}`;
}

const currentTime: string = getTime();
console.log(currentTime);
319 chars
12 lines

related categories

gistlibby LogSnag