Re: Date Format

by "David Artiss" <david(at)artiss.co.uk>

 Date:  Tue, 4 Jun 2002 16:10:05 +0100
 To:  "Stephanie Thrasher" <steph(at)omsoft.com>,
<hwg-languages(at)hwg.org>
 References:  kl19a mom
  todo: View Thread, Original
Stephanie,

Thanks for that code... it worked a treat ! I've uploaded a new version to
the same URL...

http://www.artiss71.fsworld.co.uk/date.html

Now, the code isn't quite as efficient as it should be because a couple of
the lines could easily have been concatonated together. How do you put
multiple conditions within an "IF" statement in JS ?

e.g. I'd like to put

if (date == 1 or date == 21) dateName = date + "st";

David.

----- Original Message -----
From: "Stephanie Thrasher" <steph(at)omsoft.com>
To: "David Artiss" <david(at)artiss.co.uk>; <hwg-languages(at)hwg.org>
Sent: Monday, June 03, 2002 5:10 PM
Subject: Re: Date Format


> Hi David,
>
> I think this will do it:
>
> var date = now.getDate();
> var dateName;
>  if (date == 1) dateName = "1st";
>  if (date == 2) dateName = "2nd";
>  if (date == 3) dateName = "3rd";
>  if (date == 4) dateName = "4th";
>
>
> ...etc.
>
> document.write(dayName[now.getDay()] + ", " + monName[now.getMonth()] + "
"
> + dateName);
>
> Stephanie
>
>
>
> > Hi !
> >
> > I think I'm suffering from more brain fade today. A while ago I got a
> script
> > from a site which displays the current date. It can be found at...
> >
> > http://www.artiss71.fsworld.co.uk/date.html
> >
> > It displays the date in the format "Monday, June 3". I'd like to make
this
> a
> > little more user-friendly by adding the appropriate suffix onto the end
of
> > the day - e.g. "Monday, June 3rd". However, I've been unable to work out
> > how. If anybody can assist it will be appreciated.
> >
> > David.
> >
> >
> >
>

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA