5

我正在尝试为开放时间创建一个 schema.org 定义,该定义在 Google 的丰富网页摘要测试工具中进行验证。

有了这个标记,我想定义商店在星期一的 11:00-22:00 营业。

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

但是,丰富网页摘要测试工具显示:

警告:openinghours 是指非 ISO 8601 的日期时间格式。

Schema.org定义

营业时间。营业时间可以指定为每周的时间范围,从天开始,然后是每天的时间。可以用逗号“,”列出多天,分隔每一天。使用连字符“-”指定日期或时间范围。

  • 使用以下两个字母组合指定天数:Mo、Tu、We、Th、Fr、Sa、Su。

  • 使用 24:00 时间指定时间。例如,下午 3 点指定为 15:00。

  • 这是一个例子:<time itemprop="openingHours" datetime="Tu,Th 16:00-20:00">Tuesdays and Thursdays 4-8pm</time>

4

6 回答 6

3

虽然 Google 似乎对 ptbello 的解决方案很满意,但 validator.w3.org 却不满意。

我使用data而不是time- 适用于 validator.w3.org 以及 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>

(感谢 freenode#whatwg 上的 Hixie。)

于 2014-09-11T23:40:41.450 回答
3

您还可以将 GoodRelations 中更精细的营业时间模式附加到 schema.org 节点:

<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>

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

于 2011-12-31T00:32:49.167 回答
1

经过测试,适用于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>

检查http://schema.org/openingHours

于 2014-06-10T23:48:17.093 回答
1

这个问题是已知的(参见 Schema.org 的 GitHub:关于 openingHours 的示例不应使用 'time' 元素)。

time元素不允许使用 Schema.org 示例中建议的语法。如果您想继续使用openingHours可以使用metadata元素代替time

但是openingHours,您可能希望使用更具表现力的 代替openingHoursSpecification,它将OpeningHoursSpecification(而不是具有特定格式的字符串)作为值。

于 2016-06-27T12:13:50.523 回答
0

代替

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

你可以试试这个:

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

我让它以这种方式工作。

于 2011-11-30T14:21:45.130 回答
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.

于 2011-12-30T11:46:09.493 回答