Cara Pasang Time Stamp Ala Facebook di Blog - Unik rasanya jika waktu membuat artikel blog kita mengikuti time stamp nya Facebook, visitor akan jelas mengetahui seberapa aktifnya pemilik blog dalam mengupdate artikel. Masih belum paham juga?
Jika anda sering melihat seseorang update status facebook, dibawah status ada waktu 1 jam yang lalu, dsb.. , Nah demikianlah yang akan kita buat sekarang:
Jika anda sering melihat seseorang update status facebook, dibawah status ada waktu 1 jam yang lalu, dsb.. , Nah demikianlah yang akan kita buat sekarang:
Berikut dibawah ini Cara Pasang Time Stamp Ala Facebook di Blog , yuk disimak!
1. Buka Blogger
2. Masuk Ke Template > Edit HTML
3. Cari kode </body> menggunakan CTRL + F lalu copy kode dibawah ini dan pastekan diatas kode </body>
<script type='text/javascript'>
//<![CDATA[
(function(a){if(typeof define==='function'&&define.amd){define(['jquery'],a)}else if(typeof module==='object'&&typeof module.exports==='object'){a(require('jquery'))}else{a(jQuery)}}(function($){$.timeago=function(a){if(a instanceof Date){return inWords(a)}else if(typeof a==="string"){return inWords($.timeago.parse(a))}else if(typeof a==="number"){return inWords(new Date(a))}else{return inWords($.timeago.datetime(a))}};var p=$.timeago;$.extend($.timeago,{settings:{refreshMillis:60000,allowPast:true,allowFuture:false,localeTitle:false,cutoff:0,strings:{prefixAgo:null,prefixFromNow:null,suffixAgo:"Yang Lalu",suffixFromNow:"Baru Saja",inPast:'any moment now',seconds:"Kurang dari Semenit",minute:"Sekitar Semenit",minutes:"%d menit",hour:"Sekitar satu jam",hours:"sekitar %d jam",day:"sehari",days:"%d hari",month:"sekitar sebulan",months:"%d bulan",year:"sekitar setahun",years:"%d tahun",wordSeparator:" ",numbers:[]}},inWords:function(e){if(!this.settings.allowPast&&!this.settings.allowFuture){throw'timeago allowPast and allowFuture settings can not both be set to false.';}var f=this.settings.strings;var g=f.prefixAgo;var h=f.suffixAgo;if(this.settings.allowFuture){if(e<0){g=f.prefixFromNow;h=f.suffixFromNow}}if(!this.settings.allowPast&&e>=0){return this.settings.strings.inPast}var i=Math.abs(e)/1000;var j=i/60;var k=j/60;var l=k/24;var m=l/365;function substitute(a,b){var c=$.isFunction(a)?a(b,e):a;var d=(f.numbers&&f.numbers[b])||b;return c.replace(/%d/i,d)}var n=i<45&&substitute(f.seconds,Math.round(i))||i<90&&substitute(f.minute,1)||j<45&&substitute(f.minutes,Math.round(j))||j<90&&substitute(f.hour,1)||k<24&&substitute(f.hours,Math.round(k))||k<42&&substitute(f.day,1)||l<30&&substitute(f.days,Math.round(l))||l<45&&substitute(f.month,1)||l<365&&substitute(f.months,Math.round(l/30))||m<1.5&&substitute(f.year,1)||substitute(f.years,Math.round(m));var o=f.wordSeparator||"";if(f.wordSeparator===undefined){o=" "}return $.trim([g,n,h].join(o))},parse:function(a){var s=$.trim(a);s=s.replace(/\.\d+/,"");s=s.replace(/-/,"/").replace(/-/,"/");s=s.replace(/T/," ").replace(/Z/," UTC");s=s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2");s=s.replace(/([\+\-]\d\d)$/," $100");return new Date(s)},datetime:function(a){var b=p.isTime(a)?$(a).attr("datetime"):$(a).attr("title");return p.parse(b)},isTime:function(a){return $(a).get(0).tagName.toLowerCase()==="time"}});var q={init:function(){var a=$.proxy(refresh,this);a();var b=p.settings;if(b.refreshMillis>0){this._timeagoInterval=setInterval(a,b.refreshMillis)}},update:function(a){var b=p.parse(a);$(this).data('timeago',{datetime:b});if(p.settings.localeTitle)$(this).attr("title",b.toLocaleString());refresh.apply(this)},updateFromDOM:function(){$(this).data('timeago',{datetime:p.parse(p.isTime(this)?$(this).attr("datetime"):$(this).attr("title"))});refresh.apply(this)},dispose:function(){if(this._timeagoInterval){window.clearInterval(this._timeagoInterval);this._timeagoInterval=null}}};$.fn.timeago=function(a,b){var c=a?q[a]:q.init;if(!c){throw new Error("Unknown function name '"+a+"' for timeago");}this.each(function(){c.call(this,b)});return this};function refresh(){if(!$.contains(document.documentElement,this)){$(this).timeago("dispose");return this}var a=prepareData(this);var b=p.settings;if(!isNaN(a.datetime)){if(b.cutoff==0||Math.abs(distance(a.datetime))<b.cutoff){$(this).text(inWords(a.datetime))}}return this}function prepareData(a){a=$(a);if(!a.data("timeago")){a.data("timeago",{datetime:p.datetime(a)});var b=$.trim(a.text());if(p.settings.localeTitle){a.attr("title",a.data('timeago').datetime.toLocaleString())}else if(b.length>0&&!(p.isTime(a)&&a.attr("title"))){a.attr("title",b)}}return a.data("timeago")}function inWords(a){return p.inWords(distance(a))}function distance(a){return(new Date().getTime()-a.getTime())}document.createElement("abbr");document.createElement("time")}));jQuery("abbr").timeago();
//]]>
</script>
5. Save Template.
Bagaimana, mudah bukan? Demikianlah artikel kali ini mengenai Cara Pasang Time Stamp Ala Facebook di Blog semoga bermanfaat ya!