A Discord bot that converts natural language and relative time expressions into Discord timestamps that automatically adjust to each user's timezone.
- 🕒 Natural Language Parsing: Convert phrases like "today 3pm", "tomorrow", "next friday" to timestamps
- ⏱️ Relative Time: Generate timestamps for "1 hour", "30 minutes", "2 hours 15 minutes" from now
- 🌍 Timezone Support: Set your timezone so timestamps are accurate to your location
- 📋 Multiple Formats: See all Discord timestamp formats at once
- Python 3.8 or higher
- A Discord Bot Token (Get one here)
-
Clone or download this repository
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile in the project root:cp .env.example .env
-
Add your Discord Bot Token to the
.envfile:DISCORD_TOKEN=your_bot_token_here -
Invite the bot to your server:
- Go to the Discord Developer Portal
- Select your application
- Go to OAuth2 > URL Generator
- Select scopes:
botandapplications.commands - Select bot permissions:
Send Messages,Use Slash Commands - Copy the generated URL and open it in your browser to invite the bot
python bot.pyYou should see:
Syncing commands with Discord...
Commands synced!
✅ Logged in as YourBot (ID: ...)
Bot is ready!
Convert natural language time to Discord timestamps.
Examples:
/timestamp today 3pm/timestamp tomorrow at noon/timestamp next friday 18:00/timestamp December 25 2024
Generate timestamps for a specific duration in the future.
Examples:
/in 1 hour/in 30 minutes/in 2 hours 15 minutes/in 45m(abbreviations work too!)
Set your timezone for accurate timestamp generation.
Examples:
/timezone America/New_York/timezone Europe/London/timezone Asia/Tokyo/timezone Australia/Sydney
Find your timezone: List of tz database time zones
When you generate a timestamp, the bot shows all available Discord formats:
- Short Time (
t): 9:41 PM - Long Time (
T): 9:41:30 PM - Short Date (
d): 30/06/2021 - Long Date (
D): 30 June 2021 - Short Date/Time (
f): 30 June 2021 9:41 PM - Long Date/Time (
F): Wednesday, 30 June 2021 9:41 PM - Relative (
R): 2 months ago / in 3 hours
Run the unit tests:
python -m unittest discover testsdiscord_timestamp_bot/
├── bot.py # Main bot entry point
├── requirements.txt # Python dependencies
├── .env.example # Environment variable template
├── .gitignore # Git ignore rules
├── cogs/
│ ├── __init__.py
│ └── timestamp.py # Timestamp commands cog
├── utils/
│ ├── __init__.py
│ └── time_parser.py # Time parsing utilities
└── tests/
├── __init__.py
└── test_time_parser.py # Unit tests
- Natural Language Parsing: Uses
dateparserlibrary to understand phrases like "tomorrow" or "next week" - Timezone Handling: Uses
pytzto handle timezone conversions - Discord Timestamps: Generates Unix timestamps in Discord's special format:
<t:TIMESTAMP:FORMAT> - User Preferences: Stores user timezone preferences in a JSON file
- Make sure the bot is online (check Discord server member list)
- Verify the bot has proper permissions (Send Messages, Use Slash Commands)
- Wait a few minutes after inviting the bot for commands to sync
- Try kicking and re-inviting the bot if commands don't appear
Use the IANA timezone format (e.g., America/New_York, not EST). Find yours at the timezone database.
- Be specific: "today 3pm" works better than "3pm"
- Use common date formats: "December 25" or "25 Dec" or "2024-12-25"
- For relative times, use: "1 hour", "30 minutes", "2h 15m"
This project is open source and available for personal and commercial use.