Skip to main content
Get up and running with PlatziDate quickly. This guide will walk you through installation, basic usage, and formatting dates with different locales.
1

Install PlatziDate

Install the package using your preferred package manager:
npm install platzidate
2

Get current timestamp

Use the getTimestamp() function to get the current timestamp in milliseconds:
const platzidate = require('platzidate');

const timestamp = platzidate.getTimestamp();
console.log(timestamp);
// Output: 1709572800000
The timestamp is the number of milliseconds since January 1, 1970 (Unix epoch). This is the same value returned by Date.now().
3

Format dates with getLongTime

Use the getLongTime() function to get a human-readable formatted date:
const platzidate = require('platzidate');

// Default locale (Spanish - es-ES)
const formattedDate = platzidate.getLongTime();
console.log(formattedDate);
// Output: "lunes, 4 de marzo de 2024, 12:00:00 GMT"
The formatted date includes:
  • Weekday name (long format)
  • Full date (day, month, year)
  • Time with hours, minutes, and seconds
  • Timezone abbreviation
4

Use different locales

Customize the date format by passing a locale parameter:
const platzidate = require('platzidate');

// English (US)
const usDate = platzidate.getLongTime('en-US');
console.log(usDate);
// Output: "Monday, March 4, 2024 at 12:00:00 PM GMT"

// French
const frDate = platzidate.getLongTime('fr-FR');
console.log(frDate);
// Output: "lundi 4 mars 2024 à 12:00:00 UTC"

// German
const deDate = platzidate.getLongTime('de-DE');
console.log(deDate);
// Output: "Montag, 4. März 2024 um 12:00:00 GMT"
PlatziDate supports any valid locale identifier. See the Localization Guide for more examples.

Next Steps

Now that you’re up and running, explore more of what PlatziDate can do:

API Reference

Explore the complete API documentation

Localization Guide

Learn about using different locales

Examples

See real-world usage examples

Installation

Detailed installation guide

Build docs developers (and LLMs) love