Инструменты пользователя

Инструменты сайта


works:programmer:js:common-timestamp

Работа со временем Unix Timestamp

export function timestamp(from) {
	if (from === void 0) return Math.floor(Date.now()/1000);
	if (!(from instanceof Date)) throw new TypeError("argument `from` is not valid date object");
	return Math.floor(from/1000);
}
 
export function dateFromUnix(timestamp) {
	return new Date(timestamp * 1000);
}
works/programmer/js/common-timestamp.txt · Последнее изменение: 2023/04/23 04:05 — 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki