guys i am new to java scripts and these days iam following some tutorials on w3school and lynda.
i have a big problum on classes on Jscripts.

this is my code

<script type="text/javascript">
//Write a "Good morning" greeting if
//the time is less than 10

var d=new Date();
var time=d.getHours();

if (time<10)
  document.write("<b>Good morning</b>");

this code is working fine and if i chang that "var d=new Date();" lines Date() in to "date()" the code is not working .
and again in next line "var time=d.getHours();" getHours() in to "gethours()" then again the code get wrong . so it means the java scripts have its own classes.

Recommended Answers

All 6 Replies

and i have to remember all the prefix classes on javascripts by heart

You are correct:

The function


Is not the same function as


Due to the fact that function names are case-sensitive.

It is not so hard learning the standard classes. It is easier if you learn it in practice, for example making your own clock.


most would do that in php/asp so as not to transfer as much information and keep the page the user sees (eg view source) simpler

<?php $today=getdate();
if($today['hours'] > 17) { $display='evening';} 
elseif($today['hours'] > 11) { $display='afternoon';} 
else $display = "morning"; 
echo 'Good '.$display;?>

view source Good morning

datetoday = new Date(); 
thehour = datetoday.getHours();
if (thehour > 17) display = "evening";
else if (thehour >11) display = "afternoon";
else display = "morning";
document.write("Good " + display );

View source <script type='text/javascript'>datetoday = new Date();thehour = datetoday.getHours();if (thehour > 17) display = "evening";else if (thehour >11) display = "afternoon";else display = "morning";document.write("Good " + display );</script> javascript is tediously case sensistive sensitive .......then is their any plce where i can see or get (actually study ) all the function s on Jscript.

thanx dude

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.