|
-
Feb 13th, 2003, 02:16 PM
#1
Thread Starter
Frenzied Member
Quick JS help
I have a page and I am trying to display the date, however when I use any of the getDate, getHour, etc I keep getting this result:
function getMonth() { [native code] } / function getDate() { [native code] }
I don't understand why the functions are not working, I separated them out, but none of them work, here is my code.
Code:
var d = new Date()
document.write(d.getMonth);
document.write('/');
document.write(d.getDate);
document.write('/');
document.write(d.getFullYear);
document.write(' ');
document.write(d.getHours);
document.write(':');
document.write(d.getMinutes);
document.write(':');
document.write(d.getSeconds);
Thanks!
seoptimizer2001
VB 6.0, VC++, VI, ASP, JavaScript, HTML,
Perl, XML, SQL Server 2000
If God had intended us to drink beer, He would have given us stomachs.
Please use the [code] and [vbcode] tags in your posts!
If you don't know how to use them please go HERE!

-
Feb 13th, 2003, 08:01 PM
#2
Fanatic Member
Although I don't really know why it does this... This will fix it. Note on the Month that you need to add 1 to it because it is a 0 bound array of the months.
Code:
var d = new Date()
var m = d.getMonth()
var y = d.getFullYear()
var h = d.getHours()
var mn = d.getMinutes()
var s = d.getSeconds()
document.write(m+1);
document.write('/');
document.write(d);
document.write('/');
document.write(y);
document.write(' ');
document.write(h);
document.write(':');
document.write(mn);
document.write(':');
document.write(s);
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
-
Feb 13th, 2003, 08:04 PM
#3
Thread Starter
Frenzied Member
Thanks, it was because I forgot the parentheses after all the get statements! Thanks anyways.
seoptimizer2001
VB 6.0, VC++, VI, ASP, JavaScript, HTML,
Perl, XML, SQL Server 2000
If God had intended us to drink beer, He would have given us stomachs.
Please use the [code] and [vbcode] tags in your posts!
If you don't know how to use them please go HERE!

-
Feb 14th, 2003, 07:34 AM
#4
Frenzied Member
Yeah if you leave out the parenthasis it returns the function's code. That is done so you can swap functions around, e.g.
function someFunc() {
alert('Hello');
}
document.forms[0].onsubmit = someFunc();
which would make the first form's onsubmit event hander be the same as someFunc().
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|