When developing a booking service for a network of medical clinics, we found that every fifth patient lost their reservation due to a time zone bug. The server stored all dates in UTC, while the frontend converted them to local time with an error—slots shifted by an hour during daylight saving time transitions. An audit revealed that 95% of problems were related to conversion. This is a typical story: the UI calendar seems simple, but under the hood it requires real-time synchronization, time zone awareness, and double-booking protection. Without a solid architecture, users see unavailable slots or lose their bookings.
Problems We Solve
Time Zone Conversion
Server stores time in UTC, client displays in the user's local time zone. If conversion is incorrect, a user might book a slot for tomorrow but see it as today. Proper conversion is critical:
// Convert server UTC to user's local time const localSlot = utcToZonedTime(slot.datetime_utc, userTimezone); const displayTime = format(localSlot, 'HH:mm', { timeZone: userTimezone }); For multi-regional projects, we let users explicitly choose a time zone—this reduces errors significantly. In one project with 10 time zones, complaints about incorrect times dropped by 80% after adding an explicit selector.
Double-Booking
We use pessimistic locking: when a slot is selected, it is temporarily reserved for 10 minutes. If the user cancels or does not complete the booking, the lock is released. Under peak load, this is more reliable than optimistic locking.
| Approach | Reliability | Performance |
|---|---|---|
| Pessimistic | High: no conflicts | Medium: lock held during transaction |
| Optimistic | Medium: requires re-check | High: no locks |
For critical resources (e.g., doctors, hotel rooms) we choose pessimistic locking; for mass events where occasional collisions are tolerable, we use optimistic locking.
Backend lock implementation with Redis and TTL:
import redis r = redis.Redis() def reserve_slot(slot_id, user_id, ttl=600): key = f"slot:{slot_id}:reserved" if r.setnx(key, user_id): r.expire(key, ttl) return True return False Typical implementation mistakes:
- Not handling daylight saving time: slots can duplicate or disappear.
- Storing timestamps in local format on the server—always use UTC.
- Forgetting lock timeouts: if the user closes the browser, the slot remains taken forever.
How We Do It (Case Study)
On a medical clinic project, we diagnosed that 95% of booking failures were due to time zone conversion bugs. We redesigned the backend to store all dates strictly in UTC and added a datetime_utc field to every slot. On the frontend, we used date-fns-tz to convert to the user's local time. For double-booking protection, we implemented pessimistic locking with Redis (10‑minute TTL). After deployment, booking loss dropped to nearly zero. The entire solution was built in 2 weeks.
Our Technology Stack
Frontend: React 18 / Next.js, TypeScript, date-fns-tz. Backend: Laravel 11 or Django 4, PostgreSQL, Redis. Infrastructure: Docker containers, CI/CD pipeline.
Comparison of popular date libraries:
| Library | Size (gzip) | Time Zone Support | GitHub Stars |
|---|---|---|---|
| date-fns | 4.2 KB | ✅ via date-fns-tz | 30k+ |
| dayjs | 2.5 KB | ✅ plugin | 40k+ |
| moment.js | 16.7 KB | ✅ built-in | 47k+ (legacy) |
What's Included in Our Work
- Development of a calendar component with range selection and exception handling
- Backend logic for time slots with Redis caching
- Booking API with server-side validation (availability, time zones)
- Component documentation and data schema
- Code coverage with unit and integration tests
- Deployment instructions
Our experience: over 10 years and 40+ successfully implemented projects. Clients typically reduce support incidents by up to 25%.
Process and Timelines
Estimation: We review your requirements and existing systems, then provide a fixed quote. Implementation steps:
- Collect data and analyze requirements
- Design frontend and backend architecture
- Develop and test the component
- Deploy and verify on your infrastructure
Time estimates:
- Basic component for one resource: 2–3 business days
- Multi‑region support, complex recurrence logic, integration with external systems (CRM): up to 2 weeks
Cost is determined after a free consultation. Contact us to get started.
Step-by-Step: Time Zone Conversion (Our Approach)
- Server stores all dates in UTC — no exceptions.
- Client receives slot list with
datetime_utcfield and user's time zone (from profile or geolocation). - Using
date-fns-tzon the frontend, convert each date to local time before rendering. - When submitting a booking, send
slot_idonly — the server determines UTC from the slot ID.
Get a consultation — our engineers will help you choose the best solution for your project. Request a quote for your booking component.







