5

I'm trying to create a schema.org definition for openinghours, which validates in Google's rich snippets testing tool.

With this markup I want to define that on mondays a shop is open from 11:00-22:00.

<time datetime="Mo 11:00-22:00" itemprop="openingHours">11:00-22:00</time>

However, the rich snippets testing tool displays:

Warning: openinghours refers to a datetime format that is not ISO 8601.

Schema.org defines:

The opening hours for a business. Opening hours can be specified as a weekly time range, starting with days, then times per day. Multiple days can be listed with commas ',' separating each day. Day or time ranges are specified using a hyphen '-'.

  • Days are specified using the following two-letter combinations: Mo, Tu, We, Th, Fr, Sa, Su.

  • Times are specified using 24:00 time. For example, 3pm is specified as 15:00.

  • Here is an example: <time itemprop="openingHours" datetime="Tu,Th 16:00-20:00">Tuesdays and Thursdays 4-8pm</time>

ninsky
  • 1,772
  • 23
  • 31

6 Answers6

3

While Google seems to be happy with ptbello's solution, validator.w3.org is not.

I used data instead of time - works for validator.w3.org as well as for www.google.com/webmasters/tools/richsnippets:

<data itemprop="openingHours" value="Mo-Su 07:00-22:00">7 days a week, 7 am to 22 pm</data>

(Thanks to Hixie on freenode#whatwg.)

unor
  • 92,415
  • 26
  • 211
  • 360
kamome
  • 79
  • 2
3

What you can also do is attach a more granular opening hours pattern from GoodRelations to a schema.org node:

<div itemscope itemtype="http://schema.org/Place" itemid="#store">
  <link itemprop="http://www.w3.org/1999/02/22-rdf-syntax-ns#type" 
        href="http://purl.org/goodrelations/v1#Location" />
  <span itemprop="name">Hepp's Happy Burger Restaurant</span>
  <div itemprop="http://purl.org/goodrelations/v1#hasOpeningHoursSpecification" itemscope 
       itemtype="http://purl.org/goodrelations/v1#OpeningHoursSpecification">
Opening hours: Mo-Fri,
     <link itemprop="hasOpeningHoursDayOfWeek" 
           href="http://purl.org/goodrelations/v1#Monday" />
     <link itemprop="hasOpeningHoursDayOfWeek" 
           href="http://purl.org/goodrelations/v1#Tuesday" />
     <link itemprop="hasOpeningHoursDayOfWeek" 
           href="http://purl.org/goodrelations/v1#Wednesday" />
     <link itemprop="hasOpeningHoursDayOfWeek" 
           href="http://purl.org/goodrelations/v1#Thursday" />
     <link itemprop="hasOpeningHoursDayOfWeek" 
           href="http://purl.org/goodrelations/v1#Friday" />
     <meta itemprop="opens" content="08:00:00">8:00 a.m. -
     <meta itemprop="closes" content="20:00:00">8:00 p.m.
  </div>
</div>

See

http://www.heppnetz.de/ontologies/goodrelations/v1.html#OpeningHoursSpecification

Martin Hepp
  • 1,380
  • 12
  • 20
1

Tested, works with http://www.google.com/webmasters/tools/richsnippets

<div itemscope itemtype="http://schema.org/LocalBusiness"> 
    <time itemprop="openingHours" datetime="Mo-Su 9:00-13:00 16:00-20:00">Monday through Sunday, 9:00 - 13:00, 16:00-20:00</time>.
</div>

Check http://schema.org/openingHours

ptbello
  • 21
  • 4
1

The issue is known (see on Schema.org’s GitHub: Examples on openingHours should not use the 'time' element).

The time element doesn’t allow the syntax suggested in the Schema.org examples. If you want to keep using openingHours, you could use the meta or the data element instead of time.

But instead of openingHours, you might want to use the more expressive openingHoursSpecification, which takes OpeningHoursSpecification (instead of a string with specific format) as value.

Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360
0

Instead of

<time itemprop="openingHours" datetime="Tu,Th 16:00-20:00">
Tuesdays and Thursdays 4-8pm</time>

You could try this:

<meta itemprop="openingHours" content="Tu,Th 16:00-20:00"/>
Tuesdays and Thursdays 4-8pm

I got it working this way.

J. Ypma
  • 11
  • 1
  • I'm not sure if this is legal to choose meta instead of time. If meta would be legal, than a second question arises. Is it okay to use the content attribute instead of datetime? I think schema.org should update the specs... just posted this issue on the schema.org mailing list. – ninsky Dec 09 '11 at 10:43
  • I think using is perfectly acceptable in this case. See the last example in section 2.2: http://www.w3.org/TR/microdata/#the-basic-syntax – james.garriss Dec 30 '11 at 11:45
  • 1
    I tried using meta and Google didn't recognize it here: http://www.google.com/webmasters/tools/richsnippets – MikeSchinkel Jul 14 '12 at 01:01
0

I think this is an example of where Schema.org is clashing with the Rich Snippets Testing Tool. RSTT is expecting datetime info in the ISO 8601 format, but Schema.org is allowing datetime info in another format. If you want RSTT to be happy, you'll need to comply with ISO 8601; good info about it can be found here:

http://www.w3.org/TR/NOTE-datetime

If you simply want Schema.org compliance, don't worry about the warning message.

BTW, what happens when you test your HTML here?

http://foolip.org/microdatajs/live/

This site can be a handy debugger.

james.garriss
  • 12,959
  • 7
  • 83
  • 96