AMP

amp-timeago

Provides fuzzy timestamps by formatting dates as *** time ago (for example, 3 hours ago).

Required Script <script async custom-element="amp-timeago" src="https://cdn.ampproject.org/v0/amp-timeago-0.1.js"></script>
Supported Layouts fixed, fixed-height, responsive
Examples See AMP By Example's amp-timeago example.

Behavior

Provides fuzzy timestamps that you can use on your AMP pages. This component is based on timeago.js.

Example:

<amp-timeago layout="fixed" width="160"
    height="20"
    datetime="2017-04-11T00:37:33.809Z"
    locale="en">Saturday 11 April 2017 00.37</amp-timeago>

Attributes

datetime (required) An ISO datetime. E.g. 2017-03-10T01:00:00Z (UTC) or 2017-03-09T20:00:00-05:00 (specifying timezone offset).
locale (optional)

By default, the local is set to en; however, you can specify one of the following locales:

  • ar (Arabic)
  • be (Belarusian)
  • bg (Bulgarian)
  • ca (Catalan)
  • da (Danish)
  • de (German)
  • el (Greek)
  • en (English)
  • enShort (English - short)
  • es (Spanish)
  • eu (Basque)
  • fi (Finnish)
  • fr (French)
  • he (Hebrew)
  • hu (Hungarian)
  • inBG (Bangla)
  • inHI (Hindi)
  • inID (Malay)
  • it (Italian)
  • ja (Japanese)
  • ko (Korean)
  • ml (Malayalam)
  • nbNO (Norwegian Bokmål)
  • nl (Dutch)
  • nnNO (Norwegian Nynorsk)
  • pl (Polish)
  • ptBR (Portuguese)
  • ro (Romanian)
  • ru (Russian)
  • sv (Swedish)
  • ta (Tamil)
  • th (Thai)
  • tr (Turkish)
  • uk (Ukrainian)
  • vi (Vietnamese)
  • zhCN (Chinese)
  • zhTW (Taiwanese)
cutoff (optional) Display the original date if time distance is older than cutoff (seconds).
common attributes This element includes common attributes extended to AMP components.

Validation

See amp-timeago rules in the AMP validator specification.

ご不明な点がある場合

You've read this document a dozen times but it doesn't really cover all of your questions? Maybe other people felt the same: reach out to them on Stack Overflow.

Go to Stack Overflow
Found a bug or missing a feature?

The AMP project strongly encourages your participation and contributions! We hope you'll become an ongoing participant in our open source community but we also welcome one-off contributions for the issues you're particularly passionate about.

Go to GitHub