Timestamp Converter
A simple converter designed for DiscordJS timestamps.
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
const Converter = require('timestamp-conv');
const Date = new Converter.date(1608076029);
console.log(Date.getDay());
console.log(`${Date.getDay()}.${Date.getMonth()}.${Date.getYear()}, ${Date.getHour()}:${Date.getMinute()}`);
console.log(Date.formatDay);
timestamp()
example
const Converter = require('timestamp-conv');
const Date = new Converter.timestamp('Tue, 15 Dec 2020 23:30:24 UTC');
console.log(Date.getDay());
console.log(`${Date.getDay()}.${Date.getMonth()}.${Date.getYear()}, ${Date.getHour()}:${Date.getMinute()}`);
console.log(Date.formatDay);
timestamp()
example with forceTimezone
const Converter = require('timestamp-conv');
const Date = new Converter.timestamp('2020-07-03T14:28:13.955Z', {forceTimezone: true, timezone: 1});
console.log(Date.getDay());
console.log(`${Date.getDay()}.${Date.getMonth()}.${Date.getYear()}, ${Date.getHour()}:${Date.getMinute()}`);
console.log(Date.formatDay);
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');