Skip to main content

Install via npm

PlatziDate is available on npm and can be installed using your preferred package manager.
npm install platzidate

Requirements

PlatziDate is a CommonJS module that works with Node.js and any CommonJS-compatible environment. There are no dependencies required.

System Requirements

  • Node.js: Any version that supports CommonJS modules
  • Package Manager: npm, yarn, or pnpm
  • Dependencies: None (zero dependencies!)

Verify Installation

After installing, verify that PlatziDate is working correctly:
const platzidate = require('platzidate');

// Test getTimestamp
const timestamp = platzidate.getTimestamp();
console.log('Timestamp:', timestamp);
// Output: Timestamp: 1709572800000

// Test getLongTime
const formattedDate = platzidate.getLongTime();
console.log('Formatted date:', formattedDate);
// Output: Formatted date: lunes, 4 de marzo de 2024, 12:00:00 GMT
If everything is working correctly, you should see:
  • A numeric timestamp (e.g., 1709572800000)
  • A formatted date string in Spanish locale by default (e.g., "lunes, 4 de marzo de 2024, 12:00:00 GMT")

Module Format

PlatziDate uses the CommonJS module format:
// Import the module
const platzidate = require('platzidate');

// Access the exported functions
const { getTimestamp, getLongTime } = require('platzidate');
The module exports two functions: getTimestamp and getLongTime. Both are available immediately after requiring the package.

Troubleshooting

If you see a “Cannot find module ‘platzidate’” error:
  1. Verify the package is installed: npm list platzidate
  2. Check your node_modules directory for the platzidate folder
  3. Try reinstalling: npm install platzidate --force
PlatziDate uses CommonJS (require/module.exports). If you’re using ES modules:
// This won't work - PlatziDate uses CommonJS
import platzidate from 'platzidate'; // ❌

// Use require instead
const platzidate = require('platzidate'); // ✓
PlatziDate is written in JavaScript and doesn’t include TypeScript definitions. If you’re using TypeScript, you may need to create a declaration file:
// platzidate.d.ts
declare module 'platzidate' {
  export function getTimestamp(): number;
  export function getLongTime(locale?: string): string;
}

Next Steps

Now that you have PlatziDate installed, learn how to use it:

Quickstart

Get started with PlatziDate in minutes

API Reference

Explore the complete API documentation

Examples

See real-world usage examples

Localization

Learn about locale support

Build docs developers (and LLMs) love