Here is a function I wrote to accomplish this for the day and month and also
show the four digit year.
I believe it could be modified to accomplish this.
function DateDemo(datevar, theobj)
{
var d, s;
d = new Date(datevar);
if ((d.getMonth() + 1) < 10)
{
s = '0' + (d.getMonth() + 1) + "/";
}
else
{
s = (d.getMonth() + 1) + "/";
}
if (d.getDate() < 10)
{
s += '0' + d.getDate() + "/";
}
else
{
s += d.getDate() + "/";
}
if (d.getYear() < 100)
{
if (d.getYear() < 50)
{
s += (2000 + d.getYear());
}
else
{
s += (1900 + d.getYear());
}
}
else
{
s += d.getYear();
}
theobj.value = s;
Quote:
}
hth
Anthony Sullivan MCP, GMT, GST
Analyst/Programmer
Ajilon Services, Inc
Check out the ASP FAQ! http://www.aspfaq.com
"From the mouths of babes comes ... slobber."
Quote:
>After working with the string-making functions of the Date object, it seems
>I have found a sore need for implementing something like an sprintf
>function. For example, how does one get a leading zero in the
>hours/minutes/seconds?
>If it's a waste of time to add such a function to my JS library (I've
>already started), please let me know of the built-in alternatives.
>thanx