1. BUILT-IN DATE STRINGS
<html>
<head>
<!-- --------------------------------- -->
<!-- SOPHIAKNOWS: JAVASCRIPT -->
<!-- --------------------------------- -->
<!-- BUILT-IN DATE STRINGS -->
<!-- --------------------------------- -->
<!-- Created: 2002-01-15 -->
<!-- Issued: 2003-01-15 -->
<!-- Modified: 2004-12-17 -->
<!-- Component: JS DATES -->
<!-- Copyright (c) 2001-2004 -->
<!-- Tony Pisarra, SophiaKnows -->
<!-- --------------------------------- -->
<!-- --------------------------------- -->
<!--
This page demonstrates the results of the built
in JS Date() string methods:
1. toString()
2. toLocaleString()
3. toGMTString()
Note that the results of these methods vary
somewhat between browsers and platforms with
the results of toString and toLocaleString
almost exactly reversed between most IE and
Gecko browsers
-->
<script type='text/javascript'>
var now = new Date();
</script>
</head>
<body>
<p align=center>
<script>
document.write(now.toString());
</script>
</p>
<p align=center>
<script>
document.write(now.toLocaleString());
</script>
</p>
<p align=center>
<script>
document.write(now.toGMTString());
</script>
</p>
</body>
</html>
Top^
2. US STANDARD DATE
<head>
<script type='text/javascript'>
/* --------------------------------- */
/* SOPHIAKNOWS: JAVASCRIPT */
/* --------------------------------- */
/* US STANDARD DATE */
/* --------------------------------- */
/* Created: 2002-01-15 */
/* Issued: 2003-01-15 */
/* Modified: 2004-12-17 */
/* Component: JS US STANDARD DATE */
/* Copyright (c) 2001-2004 */
/* Tony Pisarra, SophiaKnows */
/* --------------------------------- */
/* --------------------------------- */
/*
These scripts return an automated date
string in standard US 3 part numeric
format: MM/DD/YYYY
*/
var now = new Date();
// RETURN US STANDARD
function ReturnUSDate() {
var us=Return2Digits(now.getMonth()+1);
us+="/";
us+=Return2Digits(now.getDate());
us+="/";
us+=now.getFullYear();
return us;
}
// APPEND LEADING ZEROS
function Return2Digits(numin) {
return ((numin<10)?("0"+numin):numin);
}
</script>
</head>
<body>
<p align=center>
<script>
document.write(ReturnUSDate());
</script>
</p>
Top^
3. US FULL TEXT DATE
<head>
<script type='text/javascript'>
/* --------------------------------- */
/* SOPHIAKNOWS: JAVASCRIPT */
/* --------------------------------- */
/* US FULL TEXT DATE */
/* --------------------------------- */
/* Created: 2002-01-15 */
/* Issued: 2003-01-15 */
/* Modified: 2004-12-17 */
/* Component: JS US FULL TEXT DATE */
/* Copyright (c) 2001-2004 */
/* Tony Pisarra, SophiaKnows */
/* --------------------------------- */
/* --------------------------------- */
/*
These scripts return an automated date
string in standard US full-text format
*/
var now = new Date();
var fullmonths=new Array(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
)
function ReturnTextDate() {
var t=fullmonths[now.getMonth()];
t+=" ";
t+=now.getDate();
t+=", ";
t+=now.getFullYear()
return t;
}
</script>
</head>
<body>
<p align=center>
<script>
document.write(ReturnTextDate());
</script>
</p>
</body>
Top^
4. US ABBREVIATED DATE TEXT
<head>
<script type='text/javascript'>
<script type='text/javascript'>
/* --------------------------------- */
/* SOPHIAKNOWS: JAVASCRIPT */
/* --------------------------------- */
/* US SHORT DATE TEXT */
/* --------------------------------- */
/* Created: 2002-01-15 */
/* Issued: 2003-01-15 */
/* Modified: 2004-12-17 */
/* Component: JS US SHORT DATE TEXT */
/* Copyright (c) 2001-2004 */
/* Tony Pisarra, SophiaKnows */
/* --------------------------------- */
/* --------------------------------- */
/*
These scripts return an automated date
string in quasi GMT formats
*/
var now = new Date();
var shortmonths=new Array(
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
)
var shortdays=new Array(
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
)
function ReturnAbbrevDate() {
var s=shortdays[now.getDay()]
s+=", ";
s+=shortmonths[now.getMonth()];
s+=" ";
s+=now.getDate();
s+=", ";
s+=now.getFullYear();
return s;
}
</script>
</head>
<body>
<p align=center>
<script>
document.write(ReturnAbbrevDate());
</script>
</p>
</body>