0

I've been trying to make time stamps human readable on this project I am working on by using the timeago plugin for jquery.

Here is the html code I have;

<dd id="dateJoined">2016-08-04T22:30:59.920516Z</dd>

and the following is a snippet from the script I am trying to get to work;

$('dd').addClass('timeago');
$("dd.timeago").timeago();

There are no syntax errors but for some reason it does not work.

1 Answers1

2

you are using a wrong HTML element, the correct one should look like the following code. Note: you have to add datetime attribute, otherwise it won't work

<time  id="dateJoined" datetime="2008-07-17T09:24:17Z">2008-07-17T09:24:17Z</time>

where is a code pen as an example http://codepen.io/mozzi/pen/wWYdVL

if you checked the example you'll find 3 dates

  1. HTML element + datetime attribute --> works fine
  2. HTML element Without datetime attribute --> Doesn't work
  3. dd HTML element --> Doesn't work
Mina Jacob
  • 1,881
  • 22
  • 23
  • yes, you're correct I've updated the answer with an example. please check – Mina Jacob Aug 04 '16 at 23:32
  • Yes, you are correct. Thanks for the answer but do you have any idea how I can edit the time stamp in the datetime attribute by using jQuery or javascript ? –  Aug 04 '16 at 23:52