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.
• 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
.
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
.
// 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
// 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
// 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');