This project uses Day.js configured with Turkey/Istanbul timezone (Europe/Istanbul) as the default timezone for the entire application.
The following packages are installed:
dayjs- Lightweight date library- Day.js plugins for timezone support and additional functionality
The Day.js configuration is located in src/lib/dayjs.ts and includes:
utc- UTC timezone supporttimezone- Timezone conversion supportcustomParseFormat- Custom date format parsingrelativeTime- Relative time formatting (e.g., "2 hours ago")duration- Duration handlingisSameOrAfter- Date comparison utilitiesisSameOrBefore- Date comparison utilitiesweekOfYear- Week number calculationsadvancedFormat- Advanced formatting options
- Timezone:
Europe/Istanbul(Turkey/Istanbul) - Default: All date operations automatically use Turkey/Istanbul timezone
import dayjs, { TURKEY_TIMEZONE } from '@/lib/dayjs';// Get current time in Turkey/Istanbul timezone (automatic)
const now = dayjs();
// Parse a date (automatically in Turkey/Istanbul timezone)
const parsedDate = dayjs('2024-01-15 10:30:00');
// Format date in Turkey/Istanbul timezone
const formatted = dayjs().format('DD/MM/YYYY HH:mm:ss');
// Convert UTC date to Turkey/Istanbul timezone
const fromUTC = dayjs.utc('2024-01-15T10:30:00Z').tz();
// Convert Turkey/Istanbul date to UTC
const toUTC = dayjs().utc();// Get start/end of day in Turkey/Istanbul timezone
const startOfDay = dayjs().startOf('day');
const endOfDay = dayjs().endOf('day');
// Get start/end of week in Turkey/Istanbul timezone
const startOfWeek = dayjs().startOf('week');
const endOfWeek = dayjs().endOf('week');
// Get start/end of month in Turkey/Istanbul timezone
const startOfMonth = dayjs().startOf('month');
const endOfMonth = dayjs().endOf('month');// Add time in Turkey/Istanbul timezone
const futureDate = dayjs().add(2, 'hours');
const nextWeek = dayjs().add(1, 'week');
// Subtract time in Turkey/Istanbul timezone
const pastDate = dayjs().subtract(1, 'day');// Check if date is same or after another date
const isAfter = dayjs(date1).isSameOrAfter(dayjs(date2), 'day');
// Check if date is same or before another date
const isBefore = dayjs(date1).isSameOrBefore(dayjs(date2), 'hour');
// Check if before
const isExpired = dayjs(date).isBefore(dayjs());// Get relative time (e.g., "2 hours ago")
const relative = dayjs(date).fromNow();
// Get time until a future date
const timeUntil = dayjs(futureDate).toNow();// Get timezone offset in minutes
const offset = dayjs().utcOffset();
// Get timezone name
const timezoneName = dayjs().format('z');
// Get timezone abbreviation
const timezoneAbbr = dayjs().format('Z');The Prisma schema has been updated to use Europe/Istanbul as the default timezone for organizations:
model Organization {
timezone String @default("Europe/Istanbul")
// ... other fields
}Token expiration times are now calculated using Turkey/Istanbul timezone:
// Token expires in 1 hour from now (Turkey/Istanbul time)
const expires = dayjs().add(1, 'hour').toDate();- Always import from
@/lib/dayjsinstead of directly from 'dayjs' package - Timezone is automatic - no need to specify Turkey/Istanbul explicitly
- Use standard dayjs methods - all methods work automatically with configured timezone
- Convert to UTC for database storage when needed using
.utc() - Use consistent formatting throughout the application
A database migration has been applied to update existing organizations to use Europe/Istanbul timezone by default.
import dayjs from '@/lib/dayjs';
// All operations automatically use Turkey/Istanbul timezone
const now = dayjs();
const formatted = dayjs().format('DD/MM/YYYY HH:mm:ss');
const expired = dayjs(token.expires).isBefore(dayjs());
const future = dayjs().add(1, 'hour').toDate();- Timezone: Europe/Istanbul
- UTC Offset: +3 hours (UTC+3)
- Daylight Saving: Turkey does not observe daylight saving time
- Abbreviation: TRT (Turkey Time)