Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Date display


Message #1 by "Bhanu" <cbpr2@y...> on Wed, 18 Oct 2000 10:30:39 +0530
Here are some functions I use to extract display a date as Long Month, day
and Full year. (October 20, 2000). Feel free to modify as needed to obtain
your desried result

function GetLongDate()
{	
	var sLongDate = new String("")
	var dDate = new Date
	sLongDate = (GetLongMonth(dDate.getMonth())) + " " + dDate.getDate()
+ ", " + dDate.getFullYear()
	return(sLongDate)
}

function GetLongMonth(index)
{
	var MonthString=new
String("January@@@February@@March@@@@@April@@@@@May@@@@@@@June@@@@@@July@@@@
@@August@@@@September@O...@@@November@@December@@");
	var LongMonth = new String("");
	var LookupIndex;
	//
	// Calculate the string position to extract the ten letter month
	//
	index++			// bump up the index counter to use base one
	LookupIndex 	= 	((index * 10) - 10) 
	LongMonth =		MonthString.substr(LookupIndex,10)
	//
	// Now Strip out the trailing '@' characters
	//
	LongMonth = LongMonth.substr(0,LongMonth.indexOf('@'))
	return (LongMonth)
}

-----Original Message-----
From: Bhanu [mailto:cbpr2@y...]
Sent: Thursday, October 19, 2000 12:04 AM
To: javascript
Subject: [javascript] RE: Date display


What  you said works fine. But the format which i was asking for is the real
problem. how can i get it. I tried some but they are not simple.
----- Original Message -----
From: Johnson, Israel <IJohnson@R...>
To: javascript <javascript@p...>
Sent: Wednesday, October 18, 2000 8:10 PM
Subject: [javascript] RE: Date display


> This goes in the head....
> //
> function seeDay(){
> var now = new Date()
> var field = document.form1.dateDisplay
> field.value = now
> }
> ==================================
> This goes in the form...
>
> <!--Displays Date in text box -->
> <input type="Text"  size="30" name="dateDisplay">
> =========================
> <!--call the function in body onLoad handler -->

> <body onload="seeDay()">
>
>
> -----Original Message-----
> From: Bhanu [mailto:cbpr2@y...]
> Sent: Wednesday, October 18, 2000 12:41 PM
> To: javascript
> Subject: [javascript] Date display
>
>
>
> Hi every body,
>   I want to display current date in a textbox in
> (10-oct-2000) format.How can it be done using
> javascript?
>
> Thanks in advance.


  Return to Index