bitburner-src/utils/helpers/getTimestamp.ts

13 lines
485 B
TypeScript
Raw Normal View History

/**
* Returns a MM/DD HH:MM timestamp for the current time
*/
2021-05-01 09:17:31 +02:00
export function getTimestamp(): string {
2021-09-05 01:09:30 +02:00
const d: Date = new Date();
// A negative slice value takes from the end of the string rather than the beginning.
const stringWidth = -2;
const formattedHours: string = `0${d.getHours()}`.slice(stringWidth);
const formattedMinutes: string = `0${d.getMinutes()}`.slice(stringWidth);
2021-09-09 05:47:34 +02:00
return `${d.getMonth() + 1}/${d.getDate()} ${formattedHours}:${formattedMinutes}`;
}