Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
formatPosixTZ
✓ import { formatPosixTZ } from 'posixtz'
✗ import posixtz from 'posixtz'
ESM named export; package also supports CommonJS require.
parsePosixTZ
✓ const { parsePosixTZ } = require('posixtz')
✗ const parsePosixTZ = require('posixtz')
CommonJS destructure needed because module exports object with multiple functions.
getOffsetForLocalDateWithPosixTZ
✓ import { getOffsetForLocalDateWithPosixTZ } from 'posixtz'
Use named import in ESM.
formatLocalDateWithOffset
✓ import { formatLocalDateWithOffset } from 'posixtz'
Use named import in ESM.
Shows all four exported functions: converting IANA to POSIX TZ, parsing back, computing offset, and formatting with offset.
import { formatPosixTZ, parsePosixTZ, getOffsetForLocalDateWithPosixTZ, formatLocalDateWithOffset } from 'posixtz';
import moment from 'moment';
import 'moment-timezone';
const iana = 'America/Los_Angeles';
const year = 2018;
const posixStr = formatPosixTZ(iana, year);
console.log(posixStr); // 'PST8PDT,M3.2.0,M11.1.0'
const parsed = parsePosixTZ(posixStr);
console.log(parsed.dstAbbr); // 'PDT'
const offset = getOffsetForLocalDateWithPosixTZ('2018-03-11T02:00:00', posixStr);
console.log(offset); // -420 (UTC-7)
const formatted = formatLocalDateWithOffset('2018-03-11T02:00:00', posixStr);
console.log(formatted); // '2018-03-11T02:00:00-07:00'
Errors
Common errors & fixes
Cannot find module 'posixtz'
Package not installed or peer dependencies missing cause runtime errors on import.
fixRun 'npm install posixtz moment moment-timezone' in your project.
TypeError: moment(...).tz is not a function
moment-timezone not imported or not loaded.
fixAdd 'import 'moment-timezone';' or require('moment-timezone') before using posixtz functions. Module not found: Error: Can't resolve 'posixtz'
Posixtz not in node_modules; peer dependencies installation may be incomplete.
fixCheck that posixtz and peer deps are all installed correctly.
Audit
Dependencies
momentrequiredpeer dependency for time zone data and calculations
moment-timezonerequiredpeer dependency for IANA timezone data