Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek-v3-0324· DeepSeekHugging Face LMArena Human Preference 140K

Given a UTC date and time ISO string in Javascript, how do I convert this to ISO for…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with grok-3-preview-02-24’s answer.
  1. User

    Given a UTC date and time ISO string in Javascript, how do I convert this to ISO for "Europe/Paris"?

  2. DeepSeek Assistant

    Converting UTC to Europe/Paris Time in JavaScript

    To convert a UTC ISO string to Europe/Paris time (which is either UTC+1 or UTC+2 depending on daylight saving time), you can use the following approaches:

    Using Intl.DateTimeFormat (modern approach)

    function convertUTCToParisTime(utcISOString) {
      const date = new Date(utcISOString);
      return new Intl.DateTimeFormat('en-US', {
        timeZone: 'Europe/Paris',
        year: 'numeric',
        month: '2-digit',
        day: '2-digit',
        hour: '2-digit',
        minute: '2-digit',
        second: '2-digit',
        fractionalSecondDigits: 3,
        hour12: false
      }).format(date)
      .replace(/(\d+)\/(\d+)\/(\d+), (\d+:\d+:\d+)/, '$3-$1-$2T$4');
    }
    
    const utcTime = '2023-12-25T12:00:00.000Z';
    const parisTime = convertUTCToParisTime(utcTime);
    console.log(parisTime); // Outputs: "2023-12-25T13:00:00.000" (winter time)
    

    Using a library like date-fns-tz (more reliable)

    First install the package:

    npm install date-fns date-fns-tz
    

    Then use it:

    import { format } from 'date-fns';
    import { utcToZonedTime } from 'date-fns-tz';
    
    function convertUTCToParisTime(utcISOString) {
      const date = new Date(utcISOString);
      const parisTime = utcToZonedTime(date, 'Europe/Paris');
      return format(parisTime, "yyyy-MM-dd'T'HH:mm:ss.SSS", { timeZone: 'Europe/Paris' });
    }
    
    const utcTime = '2023-06-25T12:00:00.000Z';
    const parisTime = convertUTCToParisTime(utcTime);
    console.log(parisTime); // Outputs: "2023-06-25T14:00:00.000" (summer time)
    

    Using Luxon (another good library)

    import { DateTime } from 'luxon';
    
    function convertUTCToParisTime(utcISOString) {
      return DateTime.fromISO(utcISOString, { zone: 'utc' })
        .setZone('Europe/Paris')
        .toISO({ suppressMilliseconds: false });
    }
    
    const utcTime = '2023-12-25T12:00:00.000Z';
    const parisTime = convertUTCToParisTime(utcTime);
    console.log(parisTime); // Outputs: "2023-12-25T13:00:00.000+01:00"
    

    The library approaches are generally more reliable as they handle all edge cases of timezone conversion, including daylight saving time changes.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.