473,396 Members | 1,785 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 help to remove list of days from date script

Need help to remove list of days from date script. Need format "June
07, 2006"
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

// Get today's current date.
var now = new Date();

// Array list of days.
var days = new
Array('Sunday','Monday','Tuesday','Wednesday','Thu rsday','Friday','Saturday');

// Array list of months.
var months = new
Array('January','February','March','April','May',' June','July','August','September','October','Novem ber','December');

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

// Calculate four digit year.
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;
}

// Join it all together
today = days[now.getDay()] + ", " +
months[now.getMonth()] + " " +
date + ", " +
(fourdigits(now.getYear())) ;

// Print out the data.
document.write(today);

// End -->
</script>
thanks.
Mistral

Jun 7 '06 #1
9 2399
mistral wrote:
Need help to remove list of days from date script. Need format "June
07, 2006"
Some ideas below...

<SCRIPT LANGUAGE="JavaScript">
The language attribute is deprecated, type is required:

<script type="text/javascript">

<!-- Begin
Do not use HTML comments inside script elements, it is completely
unnecessary and may be harmful in some circumstances.

// Get today's current date.
var now = new Date();
That creates a date object that can be used to get the date at the time
the object was created.

// Array list of days.
var days = new
Array('Sunday','Monday','Tuesday','Wednesday','Thu rsday','Friday','Saturday');
Apparently you don't want this array, so just deleted it.

// Array list of months.
var months = new
Array('January','February','March','April','May',' June','July','August','September','October','Novem ber','December');
It can be simpler to initialise the months array with an "initialiser":

var months = ['January', 'February', 'March', 'April',
'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December'];

// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
That gets the date, not the day number. To get a 2 digit date as a
string, you could use:

var now = new Date();
var nowDate = now.getDate();
nowDate = (nowDate<10)? '0'+nowDate : ''+nowDate;
I think it's not a good idea to have a variable called 'date' when there
is a Date object (not critical, just a preference).

// Calculate four digit year.
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;
Or just:

var year = now.getFullYear();

getFullYear() is not supported by some old browsers (IE 4 at least I
think), you may need to add some feature detection or fall-back.

// Join it all together
today = days[now.getDay()] + ", " +
months[now.getMonth()] + " " +
date + ", " +
(fourdigits(now.getYear())) ;


If you aren't going to re-use the date string, write it directly:

document.write(
months[now.getMonth()] + ' ' + nowDate + ', ' + year
);
[...]
--
Rob
Jun 7 '06 #2

RobG писал(а):
mistral wrote:
Need help to remove list of days from date script. Need format "June
07, 2006" Some ideas below...

<SCRIPT LANGUAGE="JavaScript">

The language attribute is deprecated, type is required:

<script type="text/javascript">
<!-- Begin

Do not use HTML comments inside script elements, it is completely
unnecessary and may be harmful in some circumstances.
// Get today's current date.
var now = new Date();

That creates a date object that can be used to get the date at the
time
the object was created.
// Array list of days.
var days = new

Array('Sunday','Monday','Tuesday','Wednesday','Thu rsday','Friday','Saturday');

Apparently you don't want this array, so just deleted it.
// Array list of months.
var months = new

Array('January','February','March','April','May',' June','July','August','September','October','Novem ber','December');

It can be simpler to initialise the months array with an
"initialiser":

var months = ['January', 'February', 'March', 'April',
'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December'];
// Calculate the number of the current day in the week.
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();

That gets the date, not the day number. To get a 2 digit date as a
string, you could use:

var now = new Date();
var nowDate = now.getDate();
nowDate = (nowDate<10)? '0'+nowDate : ''+nowDate;
I think it's not a good idea to have a variable called 'date' when
there
is a Date object (not critical, just a preference).
// Calculate four digit year.
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;

Or just:

var year = now.getFullYear();

getFullYear() is not supported by some old browsers (IE 4 at least I
think), you may need to add some feature detection or fall-back.
// Join it all together
today = days[now.getDay()] + ", " +
months[now.getMonth()] + " " +
date + ", " +
(fourdigits(now.getYear())) ;

If you aren't going to re-use the date string, write it directly:

document.write(
months[now.getMonth()] + ' ' + nowDate + ', ' + year
);

[...]

Rob
--------------------------------------------
Hi,

I tried implement this ideas as follows, but script not work at all:

<script type="text/javascript">

var now = new Date();

var months = ['January', 'February', 'March', 'April',
'May', 'June', 'July', 'August', 'September', 'October',
'November', 'December'];

var now = new Date();

var nowDate = now.getDate();

nowDate = (nowDate<10)? '0'+nowDate : ''+nowDate;

function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;

document.write(
months[now.getMonth()] + ' ' + nowDate + ', ' + year
);

</script>

Jun 7 '06 #3
JRS: In article <11**********************@h76g2000cwa.googlegroups .com>
, dated Wed, 7 Jun 2006 09:22:38 remote, seen in
news:comp.lang.javascript, mistral <po*******@softhome.net> posted :

Please find out how to quote.
// Calculate four digit year.
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;
Missing }
Or just:

var year = now.getFullYear();

getFullYear() is not supported by some old browsers (IE 4 at least I
think), you may need to add some feature detection or fall-back.
It is supported in IE4 as supplied with Win98 first UK release.
I tried implement this ideas as follows, but script not work at all:

<script type="text/javascript">

var now = new Date();
Superfluous.

var months = ['January', 'February', 'March', 'April',
'May', 'June', 'July', 'August', 'September', 'October',
'November', 'December'];

var now = new Date();

var nowDate = now.getDate();

nowDate = (nowDate<10)? '0'+nowDate : ''+nowDate;

function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;
Needs trailing }
That fourdigits will fail in browsers in which getYear() returns
year%100; it's been said that such browsers exist(ed).

function fourdigits(number) { return 2000 + number%100 }
// should, for current date, suffice for all but the youngest
programmer.
Needs
year = fourdigits(now.getYear())
or
year = now.getFullYear()
or
year = getFY(now)

document.write(
months[now.getMonth()] + ' ' + nowDate + ', ' + year
);

</script>


Read the newsgroup FAQ; see below.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jun 7 '06 #4
I there some expert which can show how should look full correct
javascript for current date, that works normally(IE, Firefox, Netscape)
? Not comments, but full correct javascript.

mistral

Jun 8 '06 #5
JRS: In article <11**********************@j55g2000cwa.googlegroups .com>
, dated Thu, 8 Jun 2006 05:04:52 remote, seen in
news:comp.lang.javascript, mistral <po*******@softhome.net> posted :
I there some expert which can show how should look full correct
javascript for current date, that works normally(IE, Firefox, Netscape)
? Not comments, but full correct javascript.

Yes.

But, as you have ignored previous advice, experts may now ignore you.

Note, however, that Merkins often use a format, known as FFF, which
conflicts both with common sense and with the applicable international
standard.

--
John Stockton, Surrey, UK. yyww merlyn demon co uk Turnpike v4.00 MIME
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jun 8 '06 #6
Dr John Stockton said the following on 6/8/2006 4:52 PM:
JRS: In article <11**********************@j55g2000cwa.googlegroups .com>
, dated Thu, 8 Jun 2006 05:04:52 remote, seen in
news:comp.lang.javascript, mistral <po*******@softhome.net> posted :
I there some expert which can show how should look full correct
javascript for current date, that works normally(IE, Firefox, Netscape)
? Not comments, but full correct javascript. Yes.
But, as you have ignored previous advice, experts may now ignore you.


If you ignored half the posts you reply to with your pedantic garbage,
you wouldn't be half as bad.
Note, however, that Merkins often use a format, known as FFF, which
conflicts both with common sense and with the applicable international
standard.


Your pedantic stupidity never ceases to amaze me.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 8 '06 #7
> Dr John Stockton said the following on 6/8/2006 4:52 PM:

I there some expert which can show how should look full correct
javascript for current date, that works normally(IE, Firefox, Netscape)
? Not comments, but full correct javascript.
Yes.

But, as you have ignored previous advice, experts may now ignore you. If you ignored half the posts you reply to with your pedantic garbage,
you wouldn't be half as bad. Note, however, that Merkins often use a format, known as FFF, which
conflicts both with common sense and with the applicable international
standard. Your pedantic stupidity never ceases to amaze me. Randy

============================
"But, as you have ignored previous advice, experts may now ignore you."

I not ingnored previous advice, I DONT UNDERSTAND IT. If you javascript
exprert, can you you show *full and correct code snippet*? Not
comments, not abstract Usenet discussion -I dont understand it (and
your english), but human readable code snippet, ready for use in html
page?

Jun 9 '06 #8
JRS: In article <11**********************@f6g2000cwb.googlegroups. com>,
dated Fri, 9 Jun 2006 03:04:23 remote, seen in
news:comp.lang.javascript, mistral <po*******@softhome.net> posted :
"But, as you have ignored previous advice, experts may now ignore you."

I not ingnored previous advice, I DONT UNDERSTAND IT.

Which parts of "Please find out how to quote." and "Read the newsgroup
FAQ; see below." did you fail to understand?

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jun 9 '06 #9

Dr John Stockton писал(а):

JRS: In article
<11**********************@f6g2000cwb.googlegroups. com>,
dated Fri, 9 Jun 2006 03:04:23 remote, seen in
news:comp.lang.javascript, mistral <po*******@softhome.net> posted :
"But, as you have ignored previous advice, experts may now ignore you."
I not ingnored previous advice, I DONT UNDERSTAND IT. Which parts of "Please find out how to quote." and "Read the newsgroup
FAQ; see below." did you fail to understand?
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

===============================

I dont understand your expert advice - at all. Sorry.

Mistral

Jun 12 '06 #10

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

Similar topics

8
by: timmy_dale12 | last post by:
I need help with this one. I have a function that pastes a row. In each row i am pasting a link which is to call a date picker javascript function. This is the code that pastes the link : link =...
6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
19
by: Fran?ois Laroche | last post by:
hey guys, I know that you will tell me that's easier to do in php or even in asp, but I just dont have the time to learn it 1- I need a javascript that will show the date of tomorrow 2- I need a...
8
by: Tom | last post by:
Please help. I need a quick little scrpit to place on a web page that will count how many days have passed since January 1, 1970. I have ZERO experience writing ANY scripts. Anyone have any...
2
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server...
1
by: capb | last post by:
Hello, This is my first post, and any help would be greatly appreciated. I create online memorials which contain guestbooks which have been the subject of computer generated spam. I have been able...
7
by: kirke | last post by:
Hi. I want to make a list of days between two days. How can I make it??? Thx.
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
4
by: Yonih | last post by:
So I am trying to get this Calculator to work. It needs to take in a vaule, and select a shipping Everythin works great except the shipping part. I need it to take the shipping value and add it to...
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: 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
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 projectplanning, coding, testing,...

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.