JavaScript DHTML/Javascript Objects/Date — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 07:23, 26 мая 2010

"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>