hi guys im trying to make a html clock for winter-board
ive got the code now (see last post)
but when i try to combine the date element with the time element
it appears like this
12:38PM Friday, Semptember 26
but i want it like this
......12:38PM
Friday,September 26
(pretend the dots arnt there the Post thing keeps moving it)
could any one help me compile this so its like what i want
heres the date part
HTML Code:
<script language="Javascript">
<!-- Gracefully hide from old browsers
var this_weekday_name_array = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") //predefine weekday names
var this_month_name_array = new Array("January","February","March","April","May","June","July","August","September","October","November","December") //predefine month names
var this_date_timestamp=new Date() //get current day-time stamp
var this_weekday = this_date_timestamp.getDay() //extract weekday
var this_date = this_date_timestamp.getDate() //extract day of month
var this_month = this_date_timestamp.getMonth() //extract month
var this_year = this_date_timestamp.getYear() //extract year
if (this_year < 1000)
this_year+= 1900; //fix Y2K problem
if (this_year==101)
this_year=2001; //fix Netscape browsers - it displays the year as being the year 101!
var this_date_string = this_weekday_name_array[this_weekday] + ", " + this_month_name_array[this_month] + " " + this_date //concat long date string
// -->
</script>
<script language="JavaScript">document.write(this_date_string)</script>
and heres the time part
HTML Code:
<html>
<head><title>Clock</title></head>
<style>
DIV#clock {
margin-top: 40px;
margin-right: 213px;
font-family: Helvetica;
text-align: center;
color: #000;
font-size: 30px;
}
} </style>
<script type="text/javascript">
<!--
var this_weekday_name_array = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saterday")
var this_date_timestamp=new Date()
var this_weekday = this_date_timestamp.getDay()
var this_date = this_date_timestamp.getDate()
var this_month = this_date_timestamp.getMonth()
var this_year = this_date_timestamp.getYear()
if (this_year < 1000)
this_year+= 1900;
if (this_year==101)
this_year=2001;
var this_date_string = this_weekday_name_array[this_weekday] + ", "
// -->
function init ( )
{
timeDisplay = document.createTextNode ( "" );
document.getElementById("clock").appendChild ( timeDisplay );
}
function updateClock ( )
{
var currentTime = new Date ( );
var currentHours = currentTime.getHours ( );
var currentMinutes = currentTime.getMinutes ( );
var currentSeconds = currentTime.getSeconds ( );
// Pad the minutes and seconds with leading zeros, if required
currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
// Choose either "AM" or "PM" as appropriate
var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";
// Convert the hours component to 12-hour format if needed
currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
// Convert an hours component of "0" to "12"
currentHours = ( currentHours == 0 ) ? 12 : currentHours;
// Compose the string for display
var currentTimeString = currentHours + ":" + currentMinutes + timeOfDay;
// Update the time display
document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}
// -->
</script>
<body onload="updateClock(); setInterval('updateClock()', 1000 )">
<div id="clock">
</div>
</body>
</html>
thanks so much in advance!
cmon somebody's gotta know how to do it