Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CURRENT DATE AND TIME WEB PART

Status
Not open for further replies.

calixsta

Instructor
Jul 1, 2004
4
PR
Is there anything such as a current date and time web part?, if not, how can the current date and time be displayed in Sharepoint?
 
You can use javascript to do this easily. Drop this code in your page (add it to the template in default.aspx, or add it to the output of a custom webpart).

<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from old browsers
var Today = new Date();
var month;
switch (Today.getMonth()) {
case 0:
month = "January";
break;
case 1:
month = "February";
break;
case 2:
month = "March";
break;
case 3:
month = "April";
break;
case 4:
month = "May";
break;
case 5:
month = "June";
break;
case 6:
month = "July";
break;
case 7:
month = "August";
break;
case 8:
month = "September";
break;
case 9:
month = "October";
break;
case 10:
month = "November";
break;
case 11:
month = "December";
break;
}

document.write (month + " " + Today.getDate() + ", " + Today.getYear());

// end hide -->
</SCRIPT>
 
GuitarMike -
Thanks for the tip. It worked, but I need the date to be displayed in the following format: Wednesday, July 28, 2004. How can I change the format of the displayed date? For example, change the font and color. Also, I need a code to diplay the current time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top