473,394 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help with date functions

I would appreciate very much if someone could help me figure out what I am doing wrong. I have checked the code over and over and still can't figure out why it won't write to the web page. Perhaps an outside eye could help. Here goes...not sure which tags to use for .js so forgive me if I just cut/paste.

Here's my js file:
Expand|Select|Wrap|Line Numbers
  1. function XmasDays(thisDate) {
  2.    var XMYear=thisDate.getFullYear();
  3.    var XMDay=new Date("December, 25, 2005");
  4.    XMDay.setFullYear(XMYear);
  5.    var dayTotal=(XMDay-thisDate)/(1000*60*60*24);
  6.    dayTotal=Math.round(dayTotal);
  7.    return dayTotal;
  8.  
  9. function showDate(thisDate){
  10.     var thisWDay=thisDate.getDay();
  11.     var thisDay=thisDate.getDate();
  12.     var thisMonth=thisDate.getMonth();
  13.     var thisYear=thisDate.getFullYear();
  14.     var monthName=new Array(12);
  15.     monthName[0]="January";
  16.     monthName[1]="February";
  17.     monthName[2]="March";
  18.     monthName[3]="April";
  19.     monthName[4]="May";
  20.     monthName[5]="June";
  21.     monthName[6]="July";
  22.     monthName[7]="August";
  23.     monthName[8]="September";
  24.     monthName[9]="October";
  25.     monthName[10]="November";
  26.     monthName[11]="December";
  27.     var wdayName=new Array(7);
  28.     wdayName[0]="Sunday";
  29.     wdayName[1]="Monday";
  30.     wdayName[2]="Tuesday";
  31.     wdayName[3]="Wednesday";
  32.     wdayName[4]="Thursday";
  33.     wdayName[5]="Friday";
  34.     wdayName[6]="Saturday";
  35.  
  36.     dateString="weekday, month day, year";
  37.     return (wdayName[thisWDay]+","monthName[thisMonth]+","+thisYear);
  38. }
  39.  
  40.  
  41. Here's the embedded scripts:
  42. <td id="daycell">
  43. <script type="text/javascript">
  44.     <!--Hide from non-JavaScript Browsers
  45.  
  46.     var today = new Date("Mon, Dec 24, 2008");
  47.     var niceDate = showDate(today);
  48.     var daysLeft = XmasDays(today);
  49.     document.write(niceDate+"< /br>");
  50.  
  51.         if (daysLeft > 1) { 
  52.         document.write("Only "+ daysLeft+"days until Christmas");
  53.         }else if( daysLeft==1){
  54.         document.write("Last day for Christmas Shopping")
  55.         }else{
  56.         document.write("Happy Holidays from North Pole Novelties");        
  57.         }
  58.  
  59. //Stop hiding-->
  60. </script>
here's my link:
[HTML]<title>North Pole Novelties</title>
<link href="styles2.css" rel="stylesheet" type="text/css" />
<script src="library2.js" type="text/javascript"></script>
</head>[/HTML]
Feb 18 '08 #1
6 1651
acoder
16,027 Expert Mod 8TB
Is the embedded script in the body?
Feb 18 '08 #2
Yes, it's in my first cell.
Feb 20 '08 #3
Any help is appreciated. Thanks
Feb 21 '08 #4
vee10
141 100+
Hi ,

ur code is perfectly right but the wrong is in the showDate(thisdate) function

the wrong is simple syntax error ie

return (wdayName[thisWDay]+"," + monthName[thisMonth]+","+thisYear);

Place the bold one its enough


I would appreciate very much if someone could help me figure out what I am doing wrong. I have checked the code over and over and still can't figure out why it won't write to the web page. Perhaps an outside eye could help. Here goes...not sure which tags to use for .js so forgive me if I just cut/paste.
Feb 21 '08 #5
vee10
141 100+
Hi ,

ur code is perfectly right but the wrong is in the showDate(thisdate) function

the wrong is simple syntax error ie

return (wdayName[thisWDay]+"," + monthName[thisMonth]+","+thisYear);

Place the bold one its enough



Any help is appreciated. Thanks
Feb 21 '08 #6
OMG!!!! Thank you soooo much! You have no idea how much this has been driving me crazy! I figured it was something very simple. Amazingly my instructor couldn't pick that up either :) You are the man!.....or woman!
Feb 23 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Johno | last post by:
I have written the two associated base classes below (Digital_camera and Review) to manage digital camera and review objects. They are base classes for which other derived classes can be written to...
3
by: Abhas | last post by:
> > Hi, this is Abhas, > > I had made a video library program in C++, but was facing a problem. > > After entering 12 movies, i cannot enter any more movies. > > Something gibberish comes instead....
6
by: D | last post by:
Hello all...I have an issue with one of my java script functions that I'm hoping someone can easily help with. I have a web based application that we use to create/sign up for overtime. When we...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
16
by: gnawz | last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.