Inserting date on a website

Inserting date on a website

Aqua

JF-Expert Member
Joined
Jul 23, 2012
Posts
1,657
Reaction score
1,237
Hi members
I am currently working on a web project and I want to display date in a format like Wednesday 24 January2013.I have videos by Lynda from Lynda.com and I followed that concept but something is missing and the problem with videos you can not ask the presenter.Seee the code below

html code
<CODE>
<html>
<head>
<title>Dynamic changing date display</title>
<script type="text/javascript" src="\date.js"></script>
</head>
<body></body>
</html>

java script code(the date.js file)
<CODE>
window.onload=initDate;
function initDate(){
var dayName=new Array("Sunday,"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var monName=new Array("January","February","March","April","May","June","July","August","September",
"October","November","December");
var now=new Date();
var thisMonth=now.getMonth()+1;
var dtString="Today is " + dayName[now.getDay()] + ",and the date can be written as:<ul><li>";
dtString +=now.getDate() + " " + monName[now.getMonth()] + " " + now.getFullYear() + "</li></ul>";
document.getElementById("dtField").innerHTML=dtString;
}
</CODE>


In the html code there is that id=" dtField",the dtField id is missing and in the video I dd not see it may be it is in a css file that was not shown.So I would like some help from people who are developers of websites to attain that output.
The way the code is the output should be something like Today is Wednesday and the date can be written as:
.02January2013
.In the video the output displayed correctly.Once I get that I can modify it to attain what I need.
You can copy the html and js file save it,try once you succeed please let me know.This is a practical thing,if you have any concept that will give the same out put I will appreciate.Remember I have knowledge in html,css,javascript,html DOM and I am learning Jquery so whatever concept you give should apply any of the above and not a language that I am not familiar with.
Regards
Aqua
 
Hizo basics za HTML tumezisoma sana lakini at real practice siku hizi tunatumia templates ambazo zinatoa kitu very beautiful. Nilidhani unaulizia component/module ya kuinstall katika Joomla Template or something like that yenye function ya kudisplay date & time. Anyway, endelea kuchapa codes
 
Aqua unatumia script (framework kama wp, joomla etc) ama unachapa tu code? html au php?
 
Last edited by a moderator:
Kwenye html jaribu kueka sehemu (element) ambayo itakuwa na id ya "dtField".

<html>
<head>
<title>Dynamic changing date display</title>
<script type="text/javascript" src="\date.js"></script>
</head>
<body>
<div id="dtField"></div>
</body>
</html>


Huku rekebisha commas na names ("dtField")

window.onload=initDate;
function initDate(){
var dayName=new Array("Sunday","Monday","Tuesda y","Wednesday","Thursday","Fri day","Saturday");
var monName=new Array("January","February","Ma rch","April","May","June","Jul y","August","September",
"October","November","December ");
var now=new Date();
var thisMonth=now.getMonth()+1;
var dtString="Today is " + dayName[now.getDay()] + ",and the date can be written as:<ul><li>";
dtString +=now.getDate() + " " + monName[now.getMonth()] + " " + now.getFullYear() + "</li></ul>";
document.getElementById("dtField").innerHTML=dtString;
}

Its works for me!
 
Aqua unatumia script (framework kama wp, joomla etc) ama unachapa tu code? html au php?

Nachapa code html,javascript,html DOM,css na kidogo natumia Jquery(niko najifunza hii)
 
Kwenye html jaribu kueka sehemu (element) ambayo itakuwa na id ya "dtField".




Huku rekebisha commas na names ("dtField")



Its works for me!

Yah me too,thanks niko na emergence kidogo nitacheck kama ulivyonieleza nijue wapi nilikosea.Asanteni wote problem solved.Much appreciation bro.
 
Back
Top Bottom