473,378 Members | 1,384 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,378 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 2194
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.