Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General > Javascript

Notices


 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 09-26-2013, 12:05 PM   #2
jordan_rap13
Registered User
 
Join Date: Sep 2013
Location: Kalamata, Greece
Posts: 53
look at this example:

var dayarray=new Array("Sunday","Monday","Thusday","Wednesday","Thu rsday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May"," June","July","August","September","October","Novem ber","December")

function getthedate(){
var currentTime = new Date();

var day=currentTime.getDay();
var day_month = currentTime.getDate();
if (day_month<10){
day_month="0"+day_month;
}
var month = currentTime.getMonth();
var year = currentTime.getFullYear();

var hours=currentTime.getHours();
var minutes=currentTime.getMinutes();
var seconds=currentTime.getSeconds();

var last="am";
if (hours>=12){last="pm";}
if (hours>12){hours=hours-12;}
if (hours==0){hours=12;}

if (minutes<=9){minutes="0"+minutes;}
if (seconds<=9){seconds="0"+seconds;}

var ddate=dayarray[day]+"&nbsp;"+day_month+"&nbsp;"+montharray[month]+"&nbsp;"+year+",&nbsp;"+hours+":"+minutes+":"+sec onds+"&nbsp;"+last;

$(".date_time").html(ddate);

setTimeout("getthedate()",1000);
}

So the final line, will run the getthedate function every 1000ms (1 sec)
jordan_rap13 is offline   Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Implement Interfaces in JavaScript JavaScriptBank Javascript 1 03-30-2014 11:48 PM
Javascript Countdown Timer redirecting Affiliate Links JavaScriptBank Javascript 0 05-20-2013 10:29 PM
40 Super Nice JavaScript Extensions and Plugins JavaScriptBank Javascript 0 04-28-2013 11:14 PM
9 Funniest JavaScript effects JavaScriptBank Javascript 0 04-18-2013 02:13 AM
65 Free JavaScript Photo Gallery Solutions JavaScriptBank Javascript 0 04-15-2013 06:38 PM


All times are GMT -7. The time now is 11:44 PM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.