473,804 Members | 3,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with date functions

4 New Member
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.c ss" rel="stylesheet " type="text/css" />
<script src="library2.j s" type="text/javascript"></script>
</head>[/HTML]
Feb 18 '08 #1
6 1677
acoder
16,027 Recognized Expert Moderator MVP
Is the embedded script in the body?
Feb 18 '08 #2
nooby101
4 New Member
Yes, it's in my first cell.
Feb 20 '08 #3
nooby101
4 New Member
Any help is appreciated. Thanks
Feb 21 '08 #4
vee10
141 New Member
Hi ,

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

the wrong is simple syntax error ie

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

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 New Member
Hi ,

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

the wrong is simple syntax error ie

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

Place the bold one its enough



Any help is appreciated. Thanks
Feb 21 '08 #6
nooby101
4 New Member
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
1420
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 provide more detail. You'll notice that I've also declared the display functions as "virtual" to allow for polymorphism. I now need to write a function to display all the contents of an STL "deque" of pointers to Digital_camera objects. It needs...
3
2712
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. > > Can somebody please tell whats wrong?? > > This is the code : : #include<fstream.h> #include<conio.h>
6
4314
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 have holidays we require our employees to sign up in 4 hr increments for the times we post. I'm having trouble creating a time slot that ends @ 12am. 12pm and all other hours work fine for start/end times. however 12am causes problems. My actual...
16
2824
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 efficient navigating within Visual Studio 2005. Let's say your project (or solution) has dozens of forms and hundreds or even thousands of routines. Two Questions: 1) BUILT-IN to Visual Studio 2005. What ideas do you have to quickly
16
2783
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) { $page = (int)$_GET; } else { $page = 1; } // start fetching from this row number $offset = ($page - 1) * $itemPerPage; return $sql . " LIMIT $offset, $itemPerPage"; } /* Get the links to navigate between...
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10594
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10331
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.