Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Thursday February 8 2018 - 06:02:37

Date as menu item (solutions inside)


Poster: konflict37
Dated: Friday October 11 2002 - 19:06:23 BST

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.


Poster: Andy
Dated: Friday October 11 2002 - 19:19:03 BST

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

D'OH


Poster: konflict37
Dated: Friday October 11 2002 - 19:50:24 BST

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]

Silly me...


Poster: konflict37
Dated: Friday October 11 2002 - 20:26:50 BST

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

Ok now to simplify this for anyone else...


Poster: konflict37
Dated: Friday October 11 2002 - 20:37:53 BST

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
[url]stuwork1.uww.edu/~mayerzd13[/url]