javascript - HTML&CSS Change Date Formatting On Whole Web Page -
i working on portlet used multiple users throughout world, therefore change basic date format of on html page default dd/mmm/yy where mmm abbreviation because default confusing depending of country (aka usa or somewhere else)
aka 05/05/2014 should show 05/may/14 , 06/08/2015 should show 06/aug/15
since of dates need written way, maybe it's line of code in css or html file? looked around , couldn't find abbreviated dates, therefore i'd rather directly ask professionals.
i wrap dates in <time>
element, use javascript convert local date format.
html:
published <time datetime="2011-07-03">07/03</time>
js:
var elements = document.getelementsbytagname("time"); (var i=0; i<elements.length; i++) { var dat = new date('utc:'+elements[i].getattribute('datetime')); elements[i].innerhtml = dat.tolocaledatestring(); }
Comments
Post a Comment