npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@meovang/datetime-utils

v1.0.4

Published

DateTime utility functions for JavaScript

Downloads

41

Readme

@meovang/datetime-utils

A lightweight JavaScript utility library for working with dates and times. Features UTC to GMT+7 conversion and comprehensive date formatting similar to dayjs. Pure ES6 modules.

Installation

npm install @meovang/datetime-utils

Usage

import { utcToGMT7DateTime, formatDateTime } from '@meovang/datetime-utils';

// Convert UTC date to GMT+7 timezone
const utcDate = new Date('2025-10-28T08:30:00.000Z'); // UTC time
const gmt7Date = utcToGMT7DateTime(utcDate);
console.log(gmt7Date); // 2025-10-28T15:30:00.000Z (7 hours added)

// Format date with various patterns
const now = new Date();
console.log(formatDateTime(now, 'YYYY-MM-DD')); // 2025-10-28
console.log(formatDateTime(now, 'DD/MM/YYYY HH:mm:ss')); // 28/10/2025 15:30:45
console.log(formatDateTime(now, 'MMMM D, YYYY')); // October 28, 2025

API Reference

utcToGMT7DateTime(date)

Converts UTC date to GMT+7 timezone by adding 7 hours.

  • Parameters:
    • date (Date | string | number): The date to convert. Accepts Date object, date string, or timestamp
  • Returns: Date object converted to GMT+7 timezone, or original input if invalid
  • Example:
    const utcDate = new Date('2025-10-28T08:30:00.000Z');
    const gmt7Date = utcToGMT7DateTime(utcDate);
    console.log(gmt7Date); // 2025-10-28T15:30:00.000Z
      
    // Also works with strings and timestamps
    const fromString = utcToGMT7DateTime('2025-10-28T08:30:00.000Z');
    const fromTimestamp = utcToGMT7DateTime(1729853400000);

formatDateTime(date, format)

Format a date according to the provided format string using tokens similar to dayjs.

  • Parameters:
    • date (Date | string | number): The date to format. Accepts Date object, date string, or timestamp
    • format (string): Format pattern using tokens
  • Returns: Formatted date string, or original format string if date is invalid

Format Tokens

| Token | Description | Example | |-------|-------------|---------| | YYYY | Full year | 2025 | | YY | Short year | 25 | | MMMM | Full month name | January | | MMM | Short month name | Jan | | MM | Month with zero padding | 01 | | M | Month without padding | 1 | | DD | Day with zero padding | 01 | | D | Day without padding | 1 | | dddd | Full day name | Sunday | | ddd | Short day name | Sun | | dd | Minimal day name | Su | | d | Day of week (0-6) | 0 | | HH | Hours 24-hour with padding | 00-23 | | H | Hours 24-hour without padding | 0-23 | | hh | Hours 12-hour with padding | 01-12 | | h | Hours 12-hour without padding | 1-12 | | mm | Minutes with padding | 00-59 | | m | Minutes without padding | 0-59 | | ss | Seconds with padding | 00-59 | | s | Seconds without padding | 0-59 | | SSS | Milliseconds (3 digits) | 000-999 | | SS | Milliseconds (2 digits) | 00-99 | | S | Milliseconds (1 digit) | 0-9 | | A | AM/PM uppercase | AM/PM | | a | am/pm lowercase | am/pm | | X | Unix timestamp (seconds) | 1729853400 | | x | Unix timestamp (milliseconds) | 1729853400000 |

Examples

import { utcToGMT7DateTime, formatDateTime } from '@meovang/datetime-utils';

// UTC to GMT+7 conversion examples
const utcNow = new Date();
const gmt7Now = utcToGMT7DateTime(utcNow);
console.log('UTC:', utcNow.toISOString());
console.log('GMT+7:', gmt7Now.toISOString());

// Date formatting examples
const date = new Date('2025-10-28T15:30:45.123Z');

// Basic formats
console.log(formatDateTime(date, 'YYYY-MM-DD')); // 2025-10-28
console.log(formatDateTime(date, 'DD/MM/YYYY')); // 28/10/2025
console.log(formatDateTime(date, 'MM-DD-YY')); // 10-28-25

// Time formats
console.log(formatDateTime(date, 'HH:mm:ss')); // 15:30:45
console.log(formatDateTime(date, 'h:mm A')); // 3:30 PM
console.log(formatDateTime(date, 'HH:mm:ss.SSS')); // 15:30:45.123

// Full datetime formats
console.log(formatDateTime(date, 'YYYY-MM-DD HH:mm:ss')); // 2025-10-28 15:30:45
console.log(formatDateTime(date, 'MMMM D, YYYY h:mm A')); // October 28, 2025 3:30 PM
console.log(formatDateTime(date, 'dddd, MMMM D, YYYY')); // Monday, October 28, 2025

// Custom formats
console.log(formatDateTime(date, 'ddd MMM D')); // Mon Oct 28
console.log(formatDateTime(date, 'YYYY年MM月DD日')); // 2025年10月28日

// Works with different input types
console.log(formatDateTime('2025-10-28', 'YYYY-MM-DD')); // 2025-10-28
console.log(formatDateTime(1729853445123, 'YYYY-MM-DD HH:mm:ss')); // 2025-10-28 15:30:45

License

MIT

Author

Meovang

Repository

This package is part of the @meovang monorepo.