473,396 Members | 1,804 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,396 software developers and data experts.

Need some help dynamically setting day/date

I don't know javascript and was wondering if someone might give me a simple
script to dynamically display the day and date in the following format:

Sunday, October 12, 2003

Any help would be appreciated -- thanks. I'll give you credit for the script
in the comments if you want.
Jul 20 '05 #1
3 2198
Ivo

"Keith" <no@spam.com> wrote in message
news:ZG**********************@twister.nyc.rr.com.. .
I don't know javascript and was wondering if someone might give me a simple script to dynamically display the day and date in the following format:

Sunday, October 12, 2003

Any help would be appreciated -- thanks. I'll give you credit for the script in the comments if you want.


This bit of code will put the current date at the location within the body
where you choose to put this script:

<script type="text/javascript"><!--
var mydate=new Date();
var year=mydate.getFullYear();if (!year) year=mydate.getYear()+2000;
var day=mydate.getDay();
var month=mydate.getMonth();
var daym=mydate.getDate();
var dayarray=new Array("Sun","Mon","Tues","Wednes","Thurs","Fri","S atur")
var montharray=new
Array("January","February","March","April","May"," June","July","August","Sep
tember","October","November","December")
window.status=dayarray[day]+"day, "+daym+" "+montharray[month]+", "+year;
// --></script>
Jul 20 '05 #2
thanks but I just found this one--works fine:
http://www.jwweb.com/20010325.html

"Ivo" <no@thank.you> wrote in message
news:3f*********************@news.wanadoo.nl...

"Keith" <no@spam.com> wrote in message
news:ZG**********************@twister.nyc.rr.com.. .
I don't know javascript and was wondering if someone might give me a simple
script to dynamically display the day and date in the following format:

Sunday, October 12, 2003

Any help would be appreciated -- thanks. I'll give you credit for the

script
in the comments if you want.


This bit of code will put the current date at the location within the body
where you choose to put this script:

<script type="text/javascript"><!--
var mydate=new Date();
var year=mydate.getFullYear();if (!year) year=mydate.getYear()+2000;
var day=mydate.getDay();
var month=mydate.getMonth();
var daym=mydate.getDate();
var dayarray=new Array("Sun","Mon","Tues","Wednes","Thurs","Fri","S atur")
var montharray=new

Array("January","February","March","April","May"," June","July","August","Sep tember","October","November","December")
window.status=dayarray[day]+"day, "+daym+" "+montharray[month]+", "+year;
// --></script>

Jul 20 '05 #3
JRS: In article <3f*********************@news.wanadoo.nl>, seen in
news:comp.lang.javascript, Ivo <no@thank.you> posted at Sun, 12 Oct 2003
21:40:14 :-
var year=mydate.getFullYear();if (!year) year=mydate.getYear()+2000;


There is no point in coding for the attempted use of a possibly-present
method if you are going to provide code for an alternative always-
available method anyway - the user has to download both, and you need to
test both.

In fact, AIUI, getFullYear is JS 1.2, which was implemented in version 4
of two major browsers, and so is probably safe enough.

If I simulate the absence of getFullYear by mis-spelling it, I get an
error message, that year is undefined.

If I omit that statement, the if part results in an error message, that
year is undefined.

If I do just year=mydate.getYear()+2000; I get 4003; getYear()
gave 2003. It may be that, wherever getFullYear does not exist,
getYear() gives Year%100; but I rather doubt it and expect it to give
Year-1900.

I believe year = mydate.getYear()%1900 + 1900 to be safe until
end 3799, but unnecessary; and year = mydate.getYear()%100 + 2000
to be OK until end 2099. Read the FAQ.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
3
by: NewmanBT | last post by:
As you can see from the code below, several textboxes will be dynamically created and each will be tied to an org. The ChangeComment function should allow for an update to the database whenever...
8
by: Lyn | last post by:
I am trying to get my head around the concept of default, special or empty values that appear in Access VBA, depending on data type. The Access Help is not much (help), and the manual that I have...
2
by: Duncan Welch | last post by:
Hi, I've got a fairly simple date control, that I'm creating dynamically in my page. The reason for creating it dynamically is that I want the ID to vary, depending on it's situation. The...
8
by: Elliot M. Rodriguez | last post by:
I am having a heckuva time debugging this, or determining why my page is behaving this way. I have a search form, that when completed, returns a datagrid. When the user selects a row (normal...
4
by: Bob | last post by:
Hallo, I have to make a web application in Javascript/ASP for tenniscourt reservation (based on Access database). I would like to do everything with one page, because the user must be able to...
3
by: Fetty | last post by:
I have a dynamically created child grid inside of a grid. Each cell may or may not have a date in it. How do I make that date a hyperlink? Eack column has to have different links?
13
by: vgame64 | last post by:
Hi, I have been struggling with writing a program for a few hours. The requirements are that: """You will be writing a program which will determine whether a date is valid in terms of days in that...
5
by: Sam Chiu | last post by:
I am setting up a database which allows me to track down documents by due date. Apart from setting a criteria inside the query, I am hoping to use a calendar. By that, I can choose a date from the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.