Time and Date Calculation Method

Accurate time and date calculation is critical for any reporting tool. Because most Moesif customers utilize Moesif for business metrics, the Moesif platform leverages calendar-aligned time and date system. This means all time and dates conform to the calendar system:

  • Last one minute will start at top of the minute
  • Last one hour will start at top of the hour
  • Last 1 day will start at 12 AM of that day
  • Last 1 week will start at 12 AM of the first day of the week
  • Last 1 month will start at 12 AM of the first day of the month

Date Ranges

When you specify a date range with or without time, you also make use of the following comparison types:

After a specific date.
Before a specific date.

The following sections explain how Moesif calculates date ranges in combination with these comparison types.

Start Dates

For a start date or After date comparison, Moesif rounds to the beginning of the period. For example, if you specify Last 1 day, Moesif rounds to 12 AM at the beginning of that day.

End Dates

For an end date or Before date comparison, Moesif rounds to the end of that period. This effectively means the last millisecond before the next period. For example, if you say Before 1 day ago, Moesif translates this to 23:59:999 of the day before.

Moesif always includes the period that you filter. For example, consider the filter From 1 week ago to 1 week ago. This means Moesif shows data from start of the previous week to end of the previous week, not including the current week still in progress. In the same way, the filter From 1 day ago to 1 day ago represents start of yesterday to end of yesterday, whereas From 1 day ago to now means start of yesterday at midnight to now.

Partial Periods

Moesif always displays a full period of time. This means if you filter on Last week, Moesif starts the data set at 12 AM of the first day of the first full week. For example, let’s say today is Tuesday and your week starts on Monday. Then Moesif starts the period 8 days ago at 12 AM.

Time Zone

By default, Moesif uses the locale information from your browser settings for the time zone and start of week. To ensure all team members see the same data regardless of location, we recommend that you define a global time zone and start of the week for your application. For more information, see Time Zone Settings in Apps and Teams.

Changing time zone or start of the week does not update previously saved workspaces and tags. However, you can copy or resave any existing workspaces to ensure they use your latest settings.

API Query Parameters

Many of the APIs have a from and a to query parameter for filtering the dataset. These parameters can either take in an absolute date or a relative date expression. The absolute date expression conforms to ISO 8601 international standards for numerical date format. For relative dates, Moesif parses them using the format {direction}{amount}{units}.

The following units are supported:

  • s for seconds
  • m for minutes
  • d for days
  • w for weeks
  • M for months
  • y for years
  • now for current time

For example, to specify one day ago, use -1d. To specify one day from now in the future, use +1d or 1d.

now is a special alias for the current time.

While the API defaults to UTC time zone, we recommend that you specify the time_zone query parameter to ensure histograms and other metrics use the correct time zone.