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 🙏

© 2024 – Pkg Stats / Ryan Hefner

timestamp-conv

v3.0.0

Published

Discord Timestamp Converter

Downloads

104

Readme

Timestamp Converter

A simple converter designed for DiscordJS timestamps.

npm npm GitHub last commit GitHub FOSSA Status

NPM

Sometimes for some reasons module moment doesn't work properly with discord.js timestamps, so if you have some issues, this module is for you.


date

Simple-Date | date(Number, {forceTimezone: Boolean, timezone: Number}?)

Converts unix timestamp to human date.

getDayOfWeek() Returns day of the week.

getDay() Returns day of the month.

getMonth() Returns month.

getYear() Returns year.

getHour() Returns hours.

getMinute() Returns minutes.

getSeconds() Returns seconds.

getMilliseconds() Returns milliseconds.

getDaysInMonth() Returns days in the month.

formatDay Returns formatted human time in: DD.MM.YYYY.

formatHour Returns formatted human time in: DD.MM.YYYY, hh:mm.

formatSeconds Returns formatted human time in: DD.MM.YYYY, hh:mm:ss.


timestamp

Timestamp-Convert | timestamp(Date | String, {forceTimezone: Boolean, timezone: Number}?)

Converts timestamp to human date.

This class can convert DiscordJS timestamps.

getDayOfWeek() Returns day of the week.

getDay() Returns day of the month.

getMonth() Returns month.

getYear() Returns year.

getHour() Returns hours.

getMinute() Returns minutes.

getSeconds() Returns seconds.

getMilliseconds() Returns milliseconds.

getDaysInMonth() Returns days in the month.

getTimestamp Returns timestamp.

formatDay Returns formatted human time in: DD.MM.YYYY.

formatHour Returns formatted human time in: DD.MM.YYYY, hh:mm.

formatSeconds Returns formatted human time in: DD.MM.YYYY, hh:mm:ss.


Examples:

date() example

// import module
const Converter = require('timestamp-conv');

// set date to: 1608076029
const Date = new Converter.date(1608076029);

console.log(Date.getDay());
// returns day of the month (in UTC 15)

console.log(`${Date.getDay()}.${Date.getMonth()}.${Date.getYear()}, ${Date.getHour()}:${Date.getMinute()}`);
// returns: 15.12.2020, 11:47

console.log(Date.formatDay);
// returns: 15.12.2020

timestamp() example

// import module
const Converter = require('timestamp-conv');

// set date to: Tue, 15 Dec 2020 23:30:24 UTC
const Date = new Converter.timestamp('Tue, 15 Dec 2020 23:30:24 UTC');

console.log(Date.getDay());
// returns day of the month (15)

console.log(`${Date.getDay()}.${Date.getMonth()}.${Date.getYear()}, ${Date.getHour()}:${Date.getMinute()}`);
// returns: 15.12.2020, 23:30

console.log(Date.formatDay);
// returns: 15.12.2020

timestamp() example with forceTimezone

// import module
const Converter = require('timestamp-conv');

// set date to: 2020-07-03T14:28:13.955Z and force timezone to UTC+1
const Date = new Converter.timestamp('2020-07-03T14:28:13.955Z', {forceTimezone: true, timezone: 1});

console.log(Date.getDay());
// returns day of the month (03)

console.log(`${Date.getDay()}.${Date.getMonth()}.${Date.getYear()}, ${Date.getHour()}:${Date.getMinute()}`);
// returns: 03.07.2020, 15:28 (in UTC: 03.07.2020, 14:28)

console.log(Date.formatDay);
// returns: 03.07.2020

timestamp() example with DiscordJS

const Converter = require('timestamp-conv');
const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
    console.log('ready');
});

client.on('message', async (message) => {
    if(message.content === '!creationDate'){
        message.reply(`Your creation date is: ${new Converter.timestamp(message.author.createdAt).formatHour}`);
    }
});

client.login('token');