Question

J'utilise JQuery Timeajet pour faire mes dates jolies (par exemple. "Il y a 1 jour").Y a-t-il un mot-clé pour "juste maintenant" ou dois-je passer dans le temps calculé JavaScript à php?

 <abbr class='timeago' title='What do I put here?'>Just Now</abbr>

Était-ce utile?

La solution

Utilisez JQuery pour insérer l'horodatage pour vous.

var justnow = ISODateString(new Date());
$('abbr[title="just now"]').each(function() {
    $(this).attr('title', justnow);
});

où est l'isodatretring:

function ISODateString(d) {
    function pad(n) {
        return n < 10 ? '0' + n : n
    }
    return d.getUTCFullYear() + '-' + pad(d.getUTCMonth() + 1) + '-' + pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + ':' + pad(d.getUTCMinutes()) + ':' + pad(d.getUTCSeconds()) + 'Z';
}

Exemple: http://jsfiddle.net/jtbowden/rzxzl/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top