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 03:17:31 -04:00
export function getTimestamp(): string {
2021-09-04 19:09:30 -04: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-08 23:47:34 -04:00
return `${d.getMonth() + 1}/${d.getDate()} ${formattedHours}:${formattedMinutes}`;
}