❄️ Winter Sale: 28% DISCOUNT + 2x Benefits!

LEARN MORE!

How to Convert Time Duration to ISO 8601 Format

Schema.org requires the usage of the ISO 8601 format to represent durations in structured data. This ensures search engines can properly interpret time-based information, such as video lengths, podcast durations, and event schedules.

If your duration is in a standard format like “1 hour 30 minutes,” you must convert it to ISO 8601 and use it in Schema for search engines like Google to recognize.

In this knowledgebase guide, we’ll explain how to manually convert any duration into the correct ISO 8601 format.

1 What is ISO 8601 Duration Format?

ISO 8601 is an international standard for representing date and time-related data. The ISO 8601 duration format specifically defines how to express periods of time, such as the difference between two dates or times, in a standardized way.

It’s required when setting up your Schema markup in Rank Math for videos, podcasts, courses, and other time-based data.

ISO 8601 expresses time durations using a structured pattern:

PTnHnMnS

Here’s how it breaks down:

  • PT: This stands for ‘Period of Time’ and is always at the beginning.
  • {n}H for hours
  • {n}M for minutes
  • {n}S for seconds
The ISO 8601 time duration structured pattern

Here, {n} represents the number of hours, minutes, or seconds. For example:

  • 37 minutes is written as PT37M
  • 1 hour and 30 minutes is written as PT1H30M
  • 2 hours, 15 minutes, and 30 seconds is written as PT2H15M30S

2 How to Manually Convert Duration to ISO 8601 Format

To convert your time duration into ISO 8601 format, follow these steps:

2.1 Identify the Duration

First, note down the duration in hours, minutes, and seconds. For example:

If the duration is 2 hours, 15 minutes, and 30 seconds, note it as 2 hours, 15 minutes, and 30 seconds.

2.2 Use the ISO 8601 Format Rules

To convert the duration into ISO 8601 format:

  1. Start with PT: This indicates the beginning of the duration format. This is mandatory and always comes first.
  2. Include hours (H): If the duration includes hours, add the number of hours followed by H. For example, 1 hour becomes 1H.
  3. Include minutes (M): If the duration includes minutes, add the number of minutes followed by M. For example, 30 minutes becomes 30M.
  4. Include seconds (S): If the duration includes seconds, add the number of seconds followed by S. For example, 30 seconds becomes 30S.
  5. Omit zero values: If a value is 0, you can skip it. For example, if there are 0 hours, you don’t need to include 0H.

2.3 Combine the Values

Now, combine the values in the correct order: PT + hours ({n}H) + minutes ({n}M) + seconds ({n}S).

Let’s look at some examples to see how this works in practice:

Standard Time FormatConversion StepsFinal ISO 8601 Format
2 hours, 15 minutesPT → 2H → 15MPT2H15M
45 minutes, 10 secondsPT → 45M → 10SPT45M10S
1 hour, 30 secondsPT → 1H → 30SPT1H30S
50 minutesPT → 50MPT50M
3 hoursPT → 3HPT3H
1 hour, 5 minutes, and 30 secondsPT → 1H → 5M → 30SPT1H5M30S

3 A Few Special Cases to Keep in Mind

Here are some scenarios you might run into:

  1. No Hours: If the duration is less than 1 hour, only include minutes and/or seconds. For example, 37 minutes becomes PT37M, and 45 seconds becomes PT45S.
  2. No Minutes: If the duration is in whole hours, only include hours. For example, 1 hour becomes PT1H.
  3. No Seconds: If the duration doesn’t have any seconds, you can omit the S part. For example, 1 hour and 30 minutes becomes PT1H30M.

By following this guide, you can correctly format durations for structured data, improving your site’s SEO and structured data compliance. If you have any questions or need further assistance with Rank Math, feel free to reach out to our support team. They’re available 24/7, 365 days a year, and always happy to help!

Still not using Rank Math?

Setup takes less than 5 minutes including the import from your old SEO Plugin!

Learn more about the PRO Version

Still need help?

?

Submit Your Question

Please give us the details, our support team will get back to you.

Open Ticket

Related Articles