Date as menu item (solutions inside)

Please note that official support for this menu version has now ceased. There are still plenty of users, though, and the forum is still running. Some of our long-time users may be able to help you out.
Post Reply
User avatar
konflict37
Beginner
Beginner
Posts: 8
Joined: Fri Oct 11, 2002 6:54 pm
Location: US
Contact:

Date as menu item (solutions inside)

Post by konflict37 »

Well I feel like a schlep :roll: for not searching more about this,
but I have been trying to do it on and off for at least
3 months (since I found this nice menu).

What I'm trying to do is get some JavaScript code to work in
the menu that will display the date and if possible time
(time is not as important as date).

If anyone could help out I'd appreciate it.
Last edited by konflict37 on Fri Oct 11, 2002 8:28 pm, edited 1 time in total.
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Believe it or not this is so easy.

First create a variable that will hold your date like this.

Code: Select all

dte = new Date()
Then you can include this variable (or any other variable) in your menu item like this

Code: Select all

,"Date: "+dte,"#",,,1
This will show the full date but if you want to show certain date fields you should try this

Code: Select all

dte = new Date()
customdate=dte.getMonth()+"/"+dte.getDate()+"/"+dte.getYear()
Hope this helps
Andy
Last edited by Andy on Fri Oct 11, 2002 9:03 pm, edited 1 time in total.
User avatar
konflict37
Beginner
Beginner
Posts: 8
Joined: Fri Oct 11, 2002 6:54 pm
Location: US
Contact:

D'OH

Post by konflict37 »

Thanks, I was using some oldish code that I had recycled
from another project I was working on. So I was taking it
from a totally bad approach rather than yours....
*is embarassed to be a coder today :oops: *

Thanks for the response.

Heheh of course nothing is as simple as it seems...

Code: Select all

dte = new Date()
monthDayYear = dte.getMonth()+"/"+dte.getDate()+"/"+dte.getYear()
used as...

Code: Select all

,"Date: "+dte,"#",,"",1
produces long format

and...

Code: Select all

monthDayYear = dte.getMonth()+"/"+dte.getDate()+"/"+dte.getYear()
produces off by 1 month/day/year
as of today it likes to write 9/11/2002 :(

so I'm guessing

Code: Select all

mnth = dte.getMonth() + 1

will produce the proper month... *crosses fingers*

Regards,
Konflict[/code]
The shortest distance between two points is a straight line.

theKonflict
User avatar
konflict37
Beginner
Beginner
Posts: 8
Joined: Fri Oct 11, 2002 6:54 pm
Location: US
Contact:

Silly me...

Post by konflict37 »

Nope not even... man am I being foolish today
Its been far too long for working Directly in JavaScript.
Heck, all I've been doing for the last 3 months is coding
static web pages... ick!

My coding convetions gone right out the window!

Now as for the right code :!:

Code: Select all

dte = new Date() 
customdte = (dte.getMonth() +1)+"/"+dte.getDate()+"/"+dte.getYear()
There... now we have it... am I cheeseball or what? :mrgreen:
Regards,
Konflict
The shortest distance between two points is a straight line.

theKonflict
User avatar
konflict37
Beginner
Beginner
Posts: 8
Joined: Fri Oct 11, 2002 6:54 pm
Location: US
Contact:

Ok now to simplify this for anyone else...

Post by konflict37 »

The question was can you get the Date into the menu, you sure can.
It shouldn't have to be a function (where I started off :roll: and kept trying)

Date format: MM/DD/YY

Code: Select all

dte = new Date()
customdte = (dte.getMonth() + 1)+"/"+dte.getDate()+"/"+dte.getYear()
*change the / to anything you'd like for instance "alt" + 0149 = •

called in a menu as this (you can leave the word Date out if you want)

Code: Select all

,"Date: "+customdte,"#",,"",1
*Produces Date: MM/DD/YY

Go to my silly personal page
stuwork1.uww.edu/~mayerzd13
The shortest distance between two points is a straight line.

theKonflict
Post Reply