WordPress Tricks

Show Current date, week, Month and Year dynamically/automatically using Javascript and HTML in HTML or WordPress sites.

Date script ,show dateWhile developing your site, Sales funnel, landing page,Home page etc either in HTML or in WordPress, you may need to show date consists of date,week,month and year. Here i am sharing you piece of code or script (javascript and html) to show Date in your HTML or wordpress site.

So, if you want to implement the script either in HTML sales or landing pages… the first part of the code(javascript code) need to put within header html tag

<header>  ...the code will go here </header>

and the other part (“Code in Content “) will be in the place where u want to show the date.

code in header:

<SCRIPT LANGUAGE="JavaScript">
function showDate()
{
var now = new Date();
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
function fourdigits(number)
{
return (number < 1000) ? number + 1900 : number;
}
tnow=new Date();
thour=now.getHours();
tmin=now.getMinutes();
tsec=now.getSeconds();
if (tmin<=9) { tmin="0"+tmin; }
if (tsec<=9) { tsec="0"+tsec; }
if (thour<10) { thour="0"+thour; }
today = days[now.getDay()] + ", " + date + " " + months[now.getMonth()] + ", " + (fourdigits(now.getYear())) ;
document.getElementById("dateDiv").innerHTML = today;
}
setInterval("showDate()", 1000);
</script>

Code in content:

	<span style="font-size: 25px;"><strong>Date:</strong><span id="dateDiv"></span></span>

If you have any question Feel free to ask question in the comments section.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s