[thelist] Date script (java)
jsWalter
jsWalter at torres.ws
Tue May 25 09:10:16 CDT 2004
Try this...
Walter
=================
var thetime=new Date();
var nday=thetime.getDay();
var nmonth=thetime.getMonth() + 1;
var ntoday=thetime.getDate();
var nyear=thetime.getFullYear();
LONG_DAY_NAME = new Array
( "Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday", "Sunday"
);
// Convert the Day number into a String
ntoday = new String ( ntoday );
// Add a leading ZERO to make it a 2 digit Day
if ( ntoday.length < 2 )
ntoday = '0' + ntoday;
// Convert the Month number into a String
nmonth = new String ( nmonth );
// Add a leading ZERO to make it a 2 digit Month
if ( nmonth.length < 2 )
nmonth = '0' + nmonth;
document.write(nyear + '-' + nmonth + '-' + ntoday + ', ' +
LONG_DAY_NAME[nday]);
==================
> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org] On Behalf Of italPASTA
> Sent: Tuesday, May 25, 2004 8:35 AM
> To: thelist at lists.evolt.org
> Subject: [thelist] Date script (java)
>
>
> Hello,
>
> As I'm not a javascript guy, I'd like to ask u a simple
> question. I have this date script (look below) and I need it
> to write the number of day and month in 2 digits, for
> instance 05, or 07. How can I do that?
>
> Thanks in advance.
>
> <!--
> function write_date()
> {
> var thetime=new Date();
> var nday=thetime.getDay();
> var nmonth=thetime.getMonth();
> var ntoday=thetime.getDate();
> var nyear=thetime.getYear();
> var AorP=" ";
>
> if (nday==0)
> nday="Sunday";
> if (nday==1)
> nday="Monday";
> if (nday==2)
> nday="Tuesday";
> if (nday==3)
> nday="Wednesday";
> if (nday==4)
> nday="Thursday";
> if (nday==5)
> nday="Friday";
> if (nday==6)
> nday="Saturday";
>
> nmonth+=1;
>
> if (nyear<=99)
> nyear= "19"+nyear;
>
> if ((nyear>99) && (nyear<2000))
> nyear+=1900;
> document.write(""+nyear+"-"+nmonth+"-"+ntoday+", "+nday+"");
> }
> //-->
>
> --
> Regards,
> italPASTA
>
> --
> * * Please support the community that supports you. * *
http://evolt.org/help_support_evolt/
For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !
More information about the thelist
mailing list