JavaScript DHTML/Javascript Objects/Date

Материал из Web эксперт
Версия от 07:23, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

"Date" Example

 
    
<html>
<body>
<script language="javascript">
function function1(){
    var date = new Date(); 
    alert(date.toString());
}
</script>
<button onclick="function1();">Today"s date</button>
</body>
</html>



Date.toGMTString()

   
<html>
<head>
<title>A Dated Example</title>
</head></body>
<script type="text/javascript">
var dtNow = new Date();
dtNow.setDate(18);
dtNow.setMonth(10);
dtNow.setYear(2008);
dtNow.setHours(7);
dtNow.setMinutes(2);
document.writeln(dtNow.toString() + "<br />");
document.writeln(dtNow.toLocaleString() + "<br />");
document.writeln(dtNow.toLocaleDateString() + "<br />");
document.writeln(dtNow.toLocaleTimeString() + "<br />");
document.writeln(dtNow.toGMTString() + "<br />");
document.writeln(dtNow.toUTCString());
  
</script>
</body>
</html>



Date.toLocaleDateString()

   
<html>
<head>
<title>A Dated Example</title>
</head></body>
<script type="text/javascript">
var dtNow = new Date();
dtNow.setDate(18);
dtNow.setMonth(10);
dtNow.setYear(2008);
dtNow.setHours(7);
dtNow.setMinutes(2);
document.writeln(dtNow.toString() + "<br />");
document.writeln(dtNow.toLocaleString() + "<br />");
document.writeln(dtNow.toLocaleDateString() + "<br />");
document.writeln(dtNow.toLocaleTimeString() + "<br />");
document.writeln(dtNow.toGMTString() + "<br />");
document.writeln(dtNow.toUTCString());
  
</script>
</body>
</html>



Date.toLocaleString()

   
<html>
<head>
<title>A Dated Example</title>
</head></body>
<script type="text/javascript">
var dtNow = new Date();
dtNow.setDate(18);
dtNow.setMonth(10);
dtNow.setYear(2008);
dtNow.setHours(7);
dtNow.setMinutes(2);
document.writeln(dtNow.toString() + "<br />");
document.writeln(dtNow.toLocaleString() + "<br />");
document.writeln(dtNow.toLocaleDateString() + "<br />");
document.writeln(dtNow.toLocaleTimeString() + "<br />");
document.writeln(dtNow.toGMTString() + "<br />");
document.writeln(dtNow.toUTCString());
  
</script>
</body>
</html>



Date.toLocaleTimeString()

   
<html>
<head>
<title>A Dated Example</title>
</head></body>
<script type="text/javascript">
var dtNow = new Date();
dtNow.setDate(18);
dtNow.setMonth(10);
dtNow.setYear(2008);
dtNow.setHours(7);
dtNow.setMinutes(2);
document.writeln(dtNow.toString() + "<br />");
document.writeln(dtNow.toLocaleString() + "<br />");
document.writeln(dtNow.toLocaleDateString() + "<br />");
document.writeln(dtNow.toLocaleTimeString() + "<br />");
document.writeln(dtNow.toGMTString() + "<br />");
document.writeln(dtNow.toUTCString());
  
</script>
</body>
</html>



Date.toString()

   
<html>
<head>
<title>A Dated Example</title>
</head></body>
<script type="text/javascript">
var dtNow = new Date();
dtNow.setDate(18);
dtNow.setMonth(10);
dtNow.setYear(2008);
dtNow.setHours(7);
dtNow.setMinutes(2);
document.writeln(dtNow.toString() + "<br />");
document.writeln(dtNow.toLocaleString() + "<br />");
document.writeln(dtNow.toLocaleDateString() + "<br />");
document.writeln(dtNow.toLocaleTimeString() + "<br />");
document.writeln(dtNow.toGMTString() + "<br />");
document.writeln(dtNow.toUTCString());
  
</script>
</body>
</html>



Date.toUTCString()

   
<html>
<head>
<title>A Dated Example</title>
</head></body>
<script type="text/javascript">
var dtNow = new Date();
dtNow.setDate(18);
dtNow.setMonth(10);
dtNow.setYear(2008);
dtNow.setHours(7);
dtNow.setMinutes(2);
document.writeln(dtNow.toString() + "<br />");
document.writeln(dtNow.toLocaleString() + "<br />");
document.writeln(dtNow.toLocaleDateString() + "<br />");
document.writeln(dtNow.toLocaleTimeString() + "<br />");
document.writeln(dtNow.toGMTString() + "<br />");
document.writeln(dtNow.toUTCString());
  
</script>
</body>
</html>