TimeAgo functionality using jquery.timeago plugin not working in IE & Mozilla

I am trying to add a functionality of timeago in my application by using jquery.timeago plugin. I am using knockout binding to display the list of times.

It is working fine in chrome but it is not able to display data in other browsers.

Here is my script code:

    <script src="Scripts/jquery-2.1.1.min.js"></script>
    <script src="Scripts/knockout-3.2.0.js"></script>
    <script src="Scripts/jquery.timeago.js"></script>
        $(function () {
            var viewModel = {
                arr: [{
                    msgdate: new Date()
                }, {
                    msgdate: new Date()
            ko.bindingHandlers.timeago = {
                update: function (element, valueAccessor) {
                    var value = ko.utils.unwrapObservable(valueAccessor());
                    var $this = $(element);
                    $this.attr('title', value);
                    if ($this.data('timeago')) {
                        var datetime = $.timeago.datetime($this);
                        var distance = (new Date().getTime() - datetime.getTime());
                        var inWords = $.timeago.inWords(distance);
                        $this.data('timeago', { 'datetime': datetime });
                    } else {


Html part is given below: 

<div data-bind="foreach: arr">
        <div class="timeago" data-bind="timeago: msgdate"></div>


Example is here is fiddle also:


Please help me to solve it.


Last updated:10/30/2014 8:13:20 AM

1 Answers

Pawan Shukla
Pawan Shukla

Anyway jquery.timeago has explicit support for the iso8601 date format so just use the toISOString method which will work in all of the browsers:

$this.attr('title', value.toISOString());