This post is about changing the date header format to Friendlier dates the one used by Twitter and Facebook. For example : “Posted 1 day ago” like you can see in the image above. These are called Friendlier dates because by using this type of date format it becomes easy to user interpret the time when any post is done.
Now let’s get started for installing it. Save your template before making any changes. Also check the Expand Widget Templates box before editing.
Step – 1. Go to the template code editor Design >>Edit HTML and search for ]]></b:skin>.
After finding the above code place this script after the code you just found.
<script type='text/javascript'>
//<![CDATA[
function timeAgo(date1,date2,granularity){var self=this;periods=[];periods['week']=604800;periods['day']=86400;periods['hour']=3600;if(!granularity){granularity=5;}
(typeof(date1)=='string')?date1=new Date(date1).getTime()/1000:date1=new Date().getTime()/1000;(typeof(date2)=='string')?date2=new Date(date2).getTime()/1000:date2=new Date().getTime()/1000;if(date1>date2){difference=date1-date2;}else{difference=date2-date1;}
output='';for(var period in periods){var value=periods[period];if(difference>=value){time=Math.floor(difference/value);difference%=value;output=output+time+' ';if(time>1){output=output+period+'s ';}else{output=output+period+' ';}}
granularity--;if(granularity==0){break;}}
return output + ' ago.';}
$(document).ready(function(){});
//]]>
</script>
Step – 2. Now find the below code
<data:post.dateHeader/>Replace the above code with this one
<script type='text/javascript'>document.write(timeAgo('<data:post.dateHeader/>'));</script>
Step – 3. Now go to Settings >>Formatting >>Date Header Format and change the date format to the type 11/26/2010. Save the settings and its done.
No Response to "Friendlier dates for blogger"
Post a Comment