📊CSV Import Templates

Timezone Handling in CSV

Best practices for handling dates and times with timezones in CSV files.

Explanation

Proper timezone handling prevents confusion for international teams and applications.

Examples

ISO 8601 with Timezone
Output
eventName,startTimeUTC,startTimeLocal,timezone
Team Meeting,2024-12-20T14:00:00Z,2024-12-20T09:00:00,America/New_York
Product Launch,2024-12-25T10:00:00Z,2024-12-25T11:00:00,Europe/Belgrade
Webinar,2025-01-05T18:00:00Z,2025-01-05T10:00:00,America/Los_Angeles
Explicit Offset Format
Output
timestamp,value,offset
2024-12-20T14:00:00-05:00,100,EST
2024-12-20T14:00:00+01:00,200,CET
2024-12-20T14:00:00+00:00,300,UTC

Code Examples

JavaScript
// Parse dates with timezone handling
import { DateTime } from 'luxon'; // or use date-fns-tz

function parseCSVWithTimezone(csvData) {
  const records = parseCSV(csvData);
  
  return records.map(record => {
    // Option 1: Parse ISO 8601 with timezone
    const dateTime = DateTime.fromISO(record.startTimeUTC);
    
    // Option 2: Parse with explicit timezone
    const localTime = DateTime.fromISO(record.startTimeLocal, {
      zone: record.timezone
    });
    
    return {
      ...record,
      startUTC: dateTime.toJSDate(),
      startLocal: localTime.toJSDate(),
      // Convert to user's timezone
      displayTime: localTime.toLocaleString(DateTime.DATETIME_FULL)
    };
  });
}

// Alternative: Store everything in UTC
function toUTC(localTime, timezone) {
  return DateTime.fromISO(localTime, { zone: timezone })
    .toUTC()
    .toISO();
}

Try it Now

💡 Tips

  • Use ISO 8601 format with Z for UTC
  • Store timestamps in UTC, display in local time
  • Include timezone column for clarity
  • Use IANA timezone names (America/New_York)
  • Document timezone handling in import docs
  • Consider separate columns for UTC and local

⚠️ Common Pitfalls

  • Daylight saving time transitions cause confusion
  • Mixing timezone formats in same CSV
  • Assuming local timezone without stating it
  • Excel may reformat dates incorrectly
  • ISO 8601 without timezone is ambiguous