{"id":41721,"library":"php-date","title":"php-date","description":"A JavaScript library that mimics PHP's date() function for formatting Date objects. Current stable version is 4.0.1. Ships TypeScript definitions, works in Node.js and all modern browsers including IE11. Key differentiators: small size (1.2KB gzipped), supports almost all PHP date format tokens except timezone identifiers (e, T), and provides a UTC variant date.UTC(). Active development with regular releases.","status":"active","version":"4.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/loilo/node-php-date","tags":["javascript","date","format","js","util","typescript"],"install":[{"cmd":"npm install php-date","lang":"bash","label":"npm"},{"cmd":"yarn add php-date","lang":"bash","label":"yarn"},{"cmd":"pnpm add php-date","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"None - no runtime dependencies, but requires a Date object from the runtime.","package":"php-date","optional":false}],"imports":[{"note":"ESM default import is the primary usage pattern. CommonJS require is also supported but ESM is recommended for modern projects.","wrong":"const date = require('php-date')","symbol":"default","correct":"import date from 'php-date'"},{"note":"The package exports a default function; named import is not available. CommonJS require returns the function directly.","wrong":"import { date } from 'php-date'","symbol":"date","correct":"const date = require('php-date')"},{"note":"date.UTC is a property on the default export, not a separate named export. It formats in UTC timezone.","wrong":"import { UTC } from 'php-date'","symbol":"date.UTC","correct":"import date from 'php-date'; date.UTC(formatter, date)"}],"quickstart":{"code":"import date from 'php-date';\n\nconst releaseDate = new Date(2016, 9, 18);\n\n// Format like PHP's date()\nconsole.log(date('d.m.Y', releaseDate)); // 18.10.2016\nconsole.log(date('F jS Y', releaseDate)); // October 18th 2016\n\n// Using UTC variant\nconsole.log(date.UTC('Y-m-d H:i:s', new Date())); // e.g., 2025-01-15 12:00:00\n\n// Without a date argument (defaults to now)\nconsole.log(date('l, jS F Y')); // e.g., Wednesday, 15th January 2025\n","lang":"typescript","description":"Demonstrates basic formatting with PHP-style tokens, UTC variant, and defaulting to current time."},"warnings":[{"fix":"Use alternative methods like Intl.DateTimeFormat to get timezone identifiers, or avoid using those tokens.","message":"Timezone tokens 'e' and 'T' are not supported and will return an empty string.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Migrate to import date from 'php-date'","message":"CommonJS require('php-date') is still supported but ESM imports are preferred and may become default in future major versions.","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"search_vec":"'1.2':38 '4.0.1':21 'activ':59 'almost':42 'browser':31 'current':17 'date':3,11,15,45,65 'date.utc':58 'definit':24 'develop':60 'differenti':35 'e':51 'except':48 'format':14,46,66 'function':12 'gzip':40 'identifi':50 'ie11':33 'includ':32 'javascript':5,64 'js':67 'kb':39 'key':34 'librari':6 'mimic':8 'modern':30 'node.js':27 'object':16 'php':2,9,44 'php-date':1 'provid':54 'regular':62 'releas':63 'ship':22 'size':37 'small':36 'stabl':18 'support':41 'timezon':49 'token':47 'typescript':23,69 'utc':56 'util':68 'variant':57 'version':19 'work':25","created_at":"2026-06-04T18:53:46.971832+00:00","updated_at":"2026-06-04T18:53:46.971832+00:00","problems":[{"fix":"Use import date from 'php-date'","cause":"Using named import instead of default import.","error":"TypeError: date is not a function"},{"fix":"Use import date from 'php-date' or configure bundler to handle CommonJS.","cause":"Using require with CommonJS in an ESM-only environment.","error":"Uncaught ReferenceError: date is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/loilo/node-php-date#readme","github":"https://github.com/loilo/node-php-date","docs":null,"changelog":null,"pypi":null,"npm":"php-date","openapi_spec":null,"status_page":null,"smithery":null,"categories":["productivity"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}