UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

21 lines (20 loc) 862 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.gmstrftime = gmstrftime; const strftime_ts_1 = require("../datetime/strftime.js"); function gmstrftime(format, timestamp) { // discuss at: https://locutus.io/php/gmstrftime/ // parity verified: PHP 8.3 // original by: Brett Zamir (https://brett-zamir.me) // input by: Alex // bugfixed by: Brett Zamir (https://brett-zamir.me) // example 1: gmstrftime("%A", 1062462400) // returns 1: 'Tuesday' const date = typeof timestamp === 'undefined' ? new Date() : timestamp instanceof Date ? new Date(timestamp) : new Date(timestamp * 1000); const utcTimestamp = Date.parse(date.toUTCString().slice(0, -4)) / 1000; return (0, strftime_ts_1.strftime)(format, utcTimestamp); }