Manage Timezones for Projects in Mixpanel

Mixpanel records all events in Coordinated Universal Time (UTC) at intake.

Mixpanel converts the timezone to your project timezone before writing the event to Mixpanel data stores. For example, if a project is set to Pacific time (UTC -8), Mixpanel subtracts eight hours from the timestamp before recording it in the database.

If you change your project timezone, it only changes the conversion applied to new events. Old events remain in your project’s previous timezone because events are immutable–once they are recorded in Mixpanel, they cannot be changed.

Mixpanel sets project timezones by city or region. If a city or region observes Daylight Savings Time, the ingestion offset adjusts appropriately.

If you do change your project timezone, you might see a brief gap or double-counting of events, depending on the difference between the previous and new timezone. However, the timezone self-corrects as soon as the hours of time difference have passed.

This article describes how to:

Changing your Timezone

By default, Mixpanel sets your project timezone to Pacific time. 

Only project owners can change project settings.

To change the project’s timezone:

1. In PROJECT SETTINGS, select a project. 

project-settings.png

2. In Overview, select the pencil icon in the Timezone field to display a list of timezones.

timezone-field.png

3. Select a timezone and click Save.

Understanding How Timezones Affect Data

After you set your timezone correctly, you should send any dates or times to Mixpanel as Coordinated Universal Time (UTC).

By default, Mixpanel’s integration libraries work with API ingestion endpoints to automatically convert the UTC timestamp or date to your project timezone before storing your data.

Mixpanel hardcodes the project timezone date or timestamp in the backend.

Note

If you overwrite the default timestamp, import old data, or set a property that is in date format (e.g. Account Created Date), be sure to send the timestamp or date in UTC.

Sending Date Properties to Mixpanel

As mentioned previously, you should send date properties to Mixpanel as UTC time. Date properties are one of the five data types Mixpanel accepts.

For this type of property, Mixpanel recommends an iso-formatted date string (YYYY-MM-DDTHH:mm:ss) to use in your Mixpanel reports.

Below are some code examples from Mixpanel's client-side libraries that allow you to send a property to Mixpanel with a correctly formatted UTC timestamp.

Javascript: new Date().toISOString()
mixpanel.track("Sign Up", {"Account Created Date": new
Date().toISOString()});
iOS: [NSDate date]
NSDate *today = [NSDate date];
[mixpanel.people set:@{@"Account Created Date": @today}];
Android: dateFormat.format(new Date()) 
final DateFormat dateFormat = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); 
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
JSONObject props = new JSONObject(); 
try {
props.put("time-example", dateFormat.format(new Date())); 
} catch (Exception e) {
}
Mixpanel.track("Account Created Date", props);

Exporting Data from Mixpanel

When you’re exporting raw data from Mixpanel, your request requires the date parameters "from_date" and "to_date" to determine which date range of data to return.

Mixpanel's raw export machines interpret the "from_date" and "to_date" values in relation to your project’s timezone. As a result, if you request a single day of data, you receive one full day in your project’s timezone, not one full day in UTC.

As mentioned earlier, Mixpanel hardcodes event timestamps to your project’s timezone. However, the "$time" property from a raw export returns with a Unix timestamp, not a UTC timestamp.

The Unix timestamp represents the number of seconds that have elapsed since 00:00:00 on January 1, 1970 in your project’s timezone.

In the example below, if your project’s timezone is US/Pacific, the below parameters returns:

00:00:00 Aug. 1 to 11:59:59 Aug. 1 PDT, or 07:00:00 Aug. 1 – 06:59:59 Aug. 2 UTC. from_date = "2015-08-01" to_date = "2015-08-01"

Importing Data into Mixpanel

Always send imported data to Mixpanel in UTC to ensure it displays correctly in your project.

Mixpanel hardcodes timestamps of exported data to your project’s timezone. The exported data can be events and any date properties on events and people.

As a result, operations such as extract, transform, and load, need a quick timestamp and date property offset to reset the data back to UTC before importing it back to Mixpanel.

Is this article helpful?

Comments

0 comments

Article is closed for comments.