0

I am trying to setup the jQuery timeago plugin with dates in the PHP format:

d/m/Y H:i:s 

but to little success. Here is what I've done so far:

<script>
$(document).ready(function () {
    $("abbr.timeago").timeago();
});
});
</script>

<abbr class="timeago" title="30/01/2013 13:30:06">30/01/2013 13:30:06</abbr>

I've included a fiddle here: http://jsfiddle.net/mc8ft/2/

More information about the timeago plugin can be found here: http://timeago.yarp.com/

j0k
  • 22,600
  • 28
  • 79
  • 90
methuselah
  • 12,766
  • 47
  • 165
  • 315
  • There was a syntax error. I fixed it in this fiddle http://jsfiddle.net/mc8ft/3/ , but I don't see a different result, don't know what that plugin does :/ – davids Feb 06 '13 at 08:13
  • @davids Thanks, I didn't realise. There's some info on the plugin here: http://timeago.yarp.com/ – methuselah Feb 06 '13 at 08:15

2 Answers2

1

You have a syntax error in your script. remove last });.

<script>
$(document).ready(function () {
   $("abbr.timeago").timeago();
});
</script>
Devang Rathod
  • 6,650
  • 2
  • 23
  • 32
1

First off, there was a syntax error (the last }); is not needed). Secondly, it seems that the plugin does not accept the date in the format you have it in your fiddle, it should be something like yyyy/mm/dd.

Working example http://jsfiddle.net/mc8ft/4/

davids
  • 6,259
  • 3
  • 29
  • 50
  • Ah.. but all the dates in my SQL table are currently in the format d/m/Y H:i:s. Any way I can work around this? :-( – methuselah Feb 06 '13 at 08:25
  • Either you modify the plugin or modify the format of the date (hint http://stackoverflow.com/a/8040832/978515) – davids Feb 06 '13 at 08:31